Message11160

Author stefan.richthofer
Recipients jamesmudd, stefan.richthofer
Date 2017-03-03.11:13:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488539590.21.0.700888048475.issue2558@psf.upfronthosting.co.za>
In-reply-to
Content
I am actually much for improving Java integration, but IMO Strings and Enums are quite not the same (and don't even share an is-relation in any direction). Looking at https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html an Enum can also be a Planet etc, have custom properties, even methods.

Note that enumMethod in your test also wouldn't accept a String when called in Java-code.

You suggest to let Jython convert silently a String in the role of an element name into a value of Enum subtype. For me this looks like mixing up something like a lookup (e.g. in a map) with an is-relation. Or stated differently: Too much magic, even for Jython users.

That said, I would like to have a proper way to allow the method call you mention (maybe there already is?)
E.g. something like an explicit (is better than implicit...^^) way to let Jython perform Enum-lookup from Python-code.
Maybe we could have an integration with the official Python module for enums https://pypi.python.org/pypi/enum34 (for Python 3, but also backported to several Python 2 versions).

I will think about it and would also wish to hear more opinions.
History
Date User Action Args
2017-03-03 11:13:10stefan.richthofersetmessageid: <1488539590.21.0.700888048475.issue2558@psf.upfronthosting.co.za>
2017-03-03 11:13:10stefan.richthofersetrecipients: + stefan.richthofer, jamesmudd
2017-03-03 11:13:10stefan.richthoferlinkissue2558 messages
2017-03-03 11:13:08stefan.richthofercreate