<p dir="ltr"><br>
On 4 May 2013 05:17, "Georg Brandl" <<a href="mailto:g.brandl@gmx.net">g.brandl@gmx.net</a>> wrote:<br>
><br>
> Am 03.05.2013 11:40, schrieb Steven D'Aprano:<br>
> > On 03/05/13 18:42, Antoine Pitrou wrote:<br>
> >> Le Fri, 3 May 2013 09:14:22 +1000, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> a<br>
> >> écrit :<br>
> ><br>
> >>> I would suggest moving the field names into the class header for a class<br>
> >>> based convenience API:<br>
> >>><br>
> >>> class Animal(Enum, members='cat dog'): pass<br>
> >><br>
> >> This looks good to me (assuming some people don't like the special<br>
> >> attribute scheme).<br>
> ><br>
> > The problem is that this is not an expression, it is a statement. The<br>
> > advantage of the convenience function is not just that it is shorter, but<br>
> > that it is an expression.<br>
><br>
> But using that expression in any form other than<br>
><br>
> NAME = Enum('NAME', ...)<br>
><br>
> will again result in an unpicklable enum, which was the point of this thread.</p>
<p dir="ltr">Right, if all we want is a functional API that doesn't support pickling of the resulting class, that's trivial.</p>
<p dir="ltr">What I'm after is a convenience API that supports *autonumbering*, as a trivial replacement for code that currently uses "range(n)". A class statement is perfectly acceptable to me for that purpose.</p>

<p dir="ltr">Independently of that, I do like the notion of a "types.set_name(cls, dotted_name)" API that alters __name__ and __module__, while leaving __qualname__ alone.</p>
<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> Georg<br>
><br>
> _______________________________________________<br>
> Python-Dev mailing list<br>
> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
> <a href="http://mail.python.org/mailman/listinfo/python-dev">http://mail.python.org/mailman/listinfo/python-dev</a><br>
> Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com">http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com</a><br>
</p>