Jython - Can't access enumerations?

Tim Delaney timothy.c.delaney at gmail.com
Thu Nov 28 15:50:27 EST 2013


On 29 November 2013 04:22, Eamonn Rea <eamonnrea at gmail.com> wrote:

> Hello! I'm using Jython to write a game with Python/Jython/LibGDX. I
> wasn't having any trouble, and everything was going well, but sadly I can't
> access items in enumerations.
>
> If you know about the LibGDX library and have used it, you'll probably
> know about the BodyType enumeration for Box2D. I was trying to access the
> BodyType item in the enumeration. This didn't work, as Jython couldn't find
> the BodyType enumeration. I asked on the LibGDX forum and no one could
> help. So I'm hoping that someone here could help :-)
>
> So, is this a problem with LibGDX or Jython? I'm using the latest version
> of Jython.
>

There is no problems accessing the elements of enumerations with Jython.
The following was tested using Jython 2.7b1:

Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_40
Type "help", "copyright", "credits" or "license" for more information.
>>> import java.util.Collections as Collections
>>> import java.util.Arrays as Arrays
>>>
>>> a = Arrays.asList(1, 2, 3)
>>> print(a)
[1, 2, 3]
>>> e = Collections.enumeration(a)
>>> print(e)
java.util.Collections$2 at f48007e
>>>
>>> for i in e:
...     print(i)
...
1
2
3

Therefore the problem is either with LibGDX or (more likely) way you are
using it. Please post a minimal example that demonstrates the problem plus
the exact error message you get (I don't know LibGLX at all, but someone
else might, plus trimming it down to a minimal example may reveal the
problem to you).

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131129/519e3ea6/attachment.html>


More information about the Python-list mailing list