Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Nick Coghlan
On 4 May 2013 05:17, "Georg Brandl" wrote: > > Am 03.05.2013 11:40, schrieb Steven D'Aprano: > > On 03/05/13 18:42, Antoine Pitrou wrote: > >> Le Fri, 3 May 2013 09:14:22 +1000, Nick Coghlan a > >> écrit : > > > >>> I would suggest moving the field names into the class header for a class > >>> ba

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Terry Jan Reedy
On 5/3/2013 12:08 PM, Barry Warsaw wrote: Exactly right, but let's stop calling it the "convenience API" and instead call it the "functional API". I probably started the perpetuation of this problem; let's update the PEP. Please do. To me, a 'convenience function' is something like the timeit

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Georg Brandl
Am 03.05.2013 11:40, schrieb Steven D'Aprano: > On 03/05/13 18:42, Antoine Pitrou wrote: >> Le Fri, 3 May 2013 09:14:22 +1000, Nick Coghlan a >> écrit : > >>> I would suggest moving the field names into the class header for a class >>> based convenience API: >>> >>> class Animal(Enum, members='c

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Piotr Duda
2013/5/3 Barry Warsaw : > On May 03, 2013, at 07:40 PM, Steven D'Aprano wrote: > >>The problem is that this is not an expression, it is a statement. The >>advantage of the convenience function is not just that it is shorter, but >>that it is an expression. > > Exactly right, but let's stop calling

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Guido van Rossum
On Fri, May 3, 2013 at 9:08 AM, Barry Warsaw wrote: > On May 03, 2013, at 07:40 PM, Steven D'Aprano wrote: > >>The problem is that this is not an expression, it is a statement. The >>advantage of the convenience function is not just that it is shorter, but >>that it is an expression. > > Exactly r

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Barry Warsaw
On May 03, 2013, at 07:40 PM, Steven D'Aprano wrote: >The problem is that this is not an expression, it is a statement. The >advantage of the convenience function is not just that it is shorter, but >that it is an expression. Exactly right, but let's stop calling it the "convenience API" and inst

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Stefan Behnel
Ethan Furman, 02.05.2013 21:07: > In order for the Enum convenience function to be pickleable, we have this > line of code in the metaclass: > > enum_class.__module__ = sys._getframe(1).f_globals['__name__'] What a hack. And fragile, too. > This works fine for Cpython, but what about the ot

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Antoine Pitrou
Le Fri, 03 May 2013 19:40:21 +1000, Steven D'Aprano a écrit : > On 03/05/13 18:42, Antoine Pitrou wrote: > > Le Fri, 3 May 2013 09:14:22 +1000, > > Nick Coghlan a écrit : > > >> I would suggest moving the field names into the class header for a > >> class based convenience API: > >> > >> class A

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Steven D'Aprano
On 03/05/13 18:42, Antoine Pitrou wrote: Le Fri, 3 May 2013 09:14:22 +1000, Nick Coghlan a écrit : 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 looks good to me (assuming some people don't l

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Antoine Pitrou
Le Thu, 2 May 2013 14:57:35 -0700, Eli Bendersky a écrit : > > class Animal(Enum): > __values__ = 'cat dog' > > 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. Sh

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Antoine Pitrou
Le Fri, 3 May 2013 09:14:22 +1000, Nick Coghlan a écrit : > > > > 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

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Georg Brandl
Am 02.05.2013 23:57, schrieb Eli Bendersky: >> 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 > function-based. > > Debuggers are bes

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Barry Warsaw
On May 03, 2013, at 09:14 AM, Nick Coghlan wrote: >> 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 clas

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Guido van Rossum
On Thu, May 2, 2013 at 4:14 PM, Nick Coghlan wrote: > I would suggest moving the field names into the class header for a class > based convenience API: > > class Animal(Enum, members='cat dog'): pass Would you propose the same for namedtuple? -- --Guido van Rossum (python.org/~guido) __

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Nick Coghlan
On 3 May 2013 08:00, "Eli Bendersky" 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 >> function-based. >> >> Debuggers are beside the

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Jeff Hardy
On Thu, May 2, 2013 at 1:18 PM, fwierzbi...@gmail.com wrote: > On Thu, May 2, 2013 at 12:07 PM, Ethan Furman wrote: >> In order for the Enum convenience function to be pickleable, we have this >> line of code in the metaclass: >> >> enum_class.__module__ = sys._getframe(1).f_globals['__name__

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
> 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 > function-based. > > Debuggers are beside the point: there are two kinds of "convenience > syntax" on t

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Amaury Forgeot d'Arc
2013/5/2 Guido van Rossum > On Thu, May 2, 2013 at 1:18 PM, fwierzbi...@gmail.com > wrote: > > On Thu, May 2, 2013 at 12:07 PM, Ethan Furman > wrote: > >> In order for the Enum convenience function to be pickleable, we have > this > >> line of code in the metaclass: > >> > >> enum_class.__m

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Antoine Pitrou
On Thu, 2 May 2013 14:15:40 -0700 Eli Bendersky wrote: > > Sorry, but I do find the argument "let's not have a convenience syntax > because enums created with such syntax won't pickle properly from within a > debugger" not convincing enough :-) Eli, it would be nice if you stopped with this clai

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Antoine Pitrou
On Thu, 2 May 2013 14:16:34 -0700 Barry Warsaw wrote: > On May 02, 2013, at 10:57 PM, Antoine Pitrou wrote: > > >On Thu, 2 May 2013 13:48:24 -0700 > >> The problem with (5) is this: you use some library that exports an > >> enumeration, and you want to use pickling. Now you depend on the way the

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Benjamin Peterson
2013/5/2 Eli Bendersky : > > > > On Thu, May 2, 2013 at 1:10 PM, Antoine Pitrou wrote: >> >> On Thu, 2 May 2013 15:48:14 -0400 >> Benjamin Peterson wrote: >> > 2013/5/2 Ethan Furman : >> > > In order for the Enum convenience function to be pickleable, we have >> > > this >> > > line of code in th

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Barry Warsaw
On May 02, 2013, at 10:57 PM, Antoine Pitrou wrote: >On Thu, 2 May 2013 13:48:24 -0700 >> The problem with (5) is this: you use some library that exports an >> enumeration, and you want to use pickling. Now you depend on the way the >> library implemented - if it used the convenience API, you can'

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
On Thu, May 2, 2013 at 2:10 PM, Antoine Pitrou wrote: > On Thu, 2 May 2013 13:52:29 -0700 > Eli Bendersky wrote: > > > > Back to my question from before, though - do we have a real technical > > limitation of having something like inspect.what_module_am_i_now_in() > > that's supposed to work for

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
On Thu, May 2, 2013 at 2:05 PM, Ethan Furman wrote: > On 05/02/2013 01:52 PM, Eli Bendersky wrote: > >> >> Back to my question from before, though - do we have a real technical >> limitation of having something like >> inspect.what_module_am_i_now_**in() that's supposed to work for all >> Python

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Antoine Pitrou
On Thu, 2 May 2013 13:52:29 -0700 Eli Bendersky wrote: > > Back to my question from before, though - do we have a real technical > limitation of having something like inspect.what_module_am_i_now_in() > that's supposed to work for all Python code? I already gave an answer (e.g. the debugger case

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Ethan Furman
On 05/02/2013 01:52 PM, Eli Bendersky wrote: Back to my question from before, though - do we have a real technical limitation of having something like inspect.what_module_am_i_now_in() that's supposed to work for all Python code? By which you really mean inspect.what_module_was_I_called_from(

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
> > > On Thu, 2 May 2013 13:15:00 -0700 > > > Eli Bendersky wrote: > > > > > Two things that were suggested in private: > > > > > > > > > > 1) ask users to pass the module name to the convenience function > > > > > explicitly (i.e. pass "seasonmodule.Season" instead of "Season" as > the > > > > >

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Antoine Pitrou
On Thu, 2 May 2013 13:48:24 -0700 Eli Bendersky wrote: > On Thu, May 2, 2013 at 1:39 PM, Barry Warsaw wrote: > > > On May 02, 2013, at 10:18 PM, Georg Brandl wrote: > > > > >5) accept that convenience-created enums have restrictions such as no > > >picklability and point them out in the docs? >

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
On Thu, May 2, 2013 at 1:39 PM, Guido van Rossum wrote: > On Thu, May 2, 2013 at 1:18 PM, fwierzbi...@gmail.com > wrote: > > On Thu, May 2, 2013 at 12:07 PM, Ethan Furman > wrote: > >> In order for the Enum convenience function to be pickleable, we have > this > >> line of code in the metaclass

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
On Thu, May 2, 2013 at 1:39 PM, Barry Warsaw wrote: > On May 02, 2013, at 10:18 PM, Georg Brandl wrote: > > >5) accept that convenience-created enums have restrictions such as no > >picklability and point them out in the docs? > > That would work fine for me, but ultimately I'm with Guido. I jus

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Maciej Fijalkowski
On Thu, May 2, 2013 at 9:07 PM, Ethan Furman wrote: > In order for the Enum convenience function to be pickleable, we have this > line of code in the metaclass: > > enum_class.__module__ = sys._getframe(1).f_globals['__name__'] > > This works fine for Cpython, but what about the others? It's

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Antoine Pitrou
On Thu, 2 May 2013 13:33:21 -0700 Eli Bendersky wrote: > On Thu, May 2, 2013 at 1:22 PM, Antoine Pitrou wrote: > > > On Thu, 2 May 2013 13:15:00 -0700 > > Eli Bendersky wrote: > > > > Two things that were suggested in private: > > > > > > > > 1) ask users to pass the module name to the conveni

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Guido van Rossum
On Thu, May 2, 2013 at 1:18 PM, fwierzbi...@gmail.com wrote: > On Thu, May 2, 2013 at 12:07 PM, Ethan Furman wrote: >> In order for the Enum convenience function to be pickleable, we have this >> line of code in the metaclass: >> >> enum_class.__module__ = sys._getframe(1).f_globals['__name__

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Barry Warsaw
On May 02, 2013, at 10:18 PM, Georg Brandl wrote: >5) accept that convenience-created enums have restrictions such as no >picklability and point them out in the docs? That would work fine for me, but ultimately I'm with Guido. I just don't want to have to pass the module name in. -Barry ___

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
On Thu, May 2, 2013 at 1:22 PM, Antoine Pitrou wrote: > On Thu, 2 May 2013 13:15:00 -0700 > Eli Bendersky wrote: > > > Two things that were suggested in private: > > > > > > 1) ask users to pass the module name to the convenience function > > > explicitly (i.e. pass "seasonmodule.Season" instead

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread fwierzbi...@gmail.com
On Thu, May 2, 2013 at 12:07 PM, Ethan Furman wrote: > In order for the Enum convenience function to be pickleable, we have this > line of code in the metaclass: > > enum_class.__module__ = sys._getframe(1).f_globals['__name__'] > > This works fine for Cpython, but what about the others? This

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Antoine Pitrou
On Thu, 2 May 2013 13:15:00 -0700 Eli Bendersky wrote: > > Two things that were suggested in private: > > > > 1) ask users to pass the module name to the convenience function > > explicitly (i.e. pass "seasonmodule.Season" instead of "Season" as the > > class "name"). Guido doesn't like it :-) > >

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Georg Brandl
Am 02.05.2013 22:10, schrieb Antoine Pitrou: > On Thu, 2 May 2013 15:48:14 -0400 > Benjamin Peterson wrote: >> 2013/5/2 Ethan Furman : >> > In order for the Enum convenience function to be pickleable, we have this >> > line of code in the metaclass: >> > >> > enum_class.__module__ = sys._getfr

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Eli Bendersky
On Thu, May 2, 2013 at 1:10 PM, Antoine Pitrou wrote: > On Thu, 2 May 2013 15:48:14 -0400 > Benjamin Peterson wrote: > > 2013/5/2 Ethan Furman : > > > In order for the Enum convenience function to be pickleable, we have > this > > > line of code in the metaclass: > > > > > > enum_class.__mod

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Antoine Pitrou
On Thu, 2 May 2013 15:48:14 -0400 Benjamin Peterson wrote: > 2013/5/2 Ethan Furman : > > In order for the Enum convenience function to be pickleable, we have this > > line of code in the metaclass: > > > > enum_class.__module__ = sys._getframe(1).f_globals['__name__'] > > > > This works fine f

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Benjamin Peterson
2013/5/2 Ethan Furman : > In order for the Enum convenience function to be pickleable, we have this > line of code in the metaclass: > > enum_class.__module__ = sys._getframe(1).f_globals['__name__'] > > This works fine for Cpython, but what about the others? Regardless of that, perhaps we sho

[Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-02 Thread Ethan Furman
In order for the Enum convenience function to be pickleable, we have this line of code in the metaclass: enum_class.__module__ = sys._getframe(1).f_globals['__name__'] This works fine for Cpython, but what about the others? -- ~Ethan~ ___ Python-