[Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity
ncoghlan at gmail.com
Fri May 3 01:14:22 CEST 2013
On 3 May 2013 08:00, "Eli Bendersky" <eliben at gmail.com> wrote:
> > Eli, it would be nice if you stopped with this claim.
>> I'm not advocating "not having a convenience syntax", I'm advocating
>> having a convenience syntax which is *class-based* rather than
>> Debuggers are beside the point: there are two kinds of "convenience
>> syntax" on the table; one allows pickling by construction, one
>> requires an ugly hack which may not solve all cases (and which may
>> apparently make Jython / IronPython mildly unhappy). Why you insist
>> on ignoring the former and imposing the latter is beyond me.
> I'm not trying to belittle our class-based suggestion. I just think there
are two separate issues here, and I was focusing on just one of them for
now. The one I've been focusing on is how to make the function-based
convenience syntax work with pickling in the vast majority of interesting
cases. This appears to be possible by using the same pattern used by
namedtuple, and even better by encapsulating this pattern formally in
stdlib so it stops being a hack (and may actually be useful for other code
> The other issue is your proposal to have a class-based convenience syntax
akin to (correct me if I got this wrong):
> class Animal(Enum):
> __values__ = 'cat dog'
I would suggest moving the field names into the class header for a class
based convenience API:
class Animal(Enum, members='cat dog'): pass
> This is obviously a matter of preference (and hence bikeshedding), but
this still looks better to me:
> Animal = Enum('Animal', 'cat dog')
> It has two advantages:
> 1. Shorter
> 2. Parallels namedtuple, which is by now a well known and widely used
> On the other hand, your proposal has the advantage that it allows pickles
without hacks in the implementation.
> Did I sum up the issues fairly?
> I don't know what to decide here. There's no clear technical merit to
decide on one against the other (IMHO!), it's a matter of preference.
Hopefully Guido will step in and save us from our misery ;-)
> Python-Dev mailing list
> Python-Dev at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev