0

I am using JEPP - java embedded python, I am trying to send a arraylist from java to python. while receiving the arraylist in python its type is jep.PyJList. now i have to cast that type(jep.PyJList) to normal python list.

1 Answers1

1

PyJList was designed to support the concept of duck typing, wherever possible it supports all the operations that you can do on a normal python list. For most use cases there is no good reason to convert it to a normal python list, just use the PyJList as though it were a list.

If there is some reason that the duck typing is not good enough and you really do need a normal python list you can just use the list constructor method to create a new list just as you would with any other python sequence type. The following shows an example of converting an ArrayList to a list using the jep interactive console:

>>> from java.util import ArrayList
>>> a = ArrayList()
>>> type(a)
<type 'jep.PyJList'>
>>> b = list(a)
>>> type(b)
<type 'list'>
bsteffen
  • 371
  • 2
  • 9