Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Nick Coghlan
On 24 Sep 2013 08:09, "Greg Ewing" wrote: > > Steven D'Aprano wrote: >> >> It might not be a rule, but it's certainly the norm. I reckon that class attributes that aren't accessible from the instance are significantly more surprising than Color.red.blue. > > > There are really two different kinds

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Greg Ewing
Steven D'Aprano wrote: It might not be a rule, but it's certainly the norm. I reckon that class attributes that aren't accessible from the instance are significantly more surprising than Color.red.blue. There are really two different kinds of things that we refer to as "class attributes". One

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Stephen J. Turnbull
Guido van Rossum writes: > On Mon, Sep 23, 2013 at 8:17 AM, Zero Piraeus wrote: >> On Mon, Sep 23, 2013 at 09:45:46AM -0400, Chris Lambacher wrote: >>> [...] An example of how this will be used in practice is:> >>>     {% if object.state == object.state.completed %} >>>       some html >>>

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Guido van Rossum
I am quickly losing interest in this -- I was only jumping in because I feared there was support for making Color.red.blue "work". I don't think I hve to worry about that any more -- what's best for Django templates is up to the template author. On Mon, Sep 23, 2013 at 10:46 AM, Stephen J. Turnbu

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Zero Piraeus
On Mon, Sep 23, 2013 at 09:45:46AM -0400, Chris Lambacher wrote: > [...] The exact use case is in Django templates where a value comes > from the database. If you want to compare you either have to use > __class__ which I would say is a code smell, or you have > to provide the Enum class. I'm havi

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Guido van Rossum
On Mon, Sep 23, 2013 at 8:17 AM, Zero Piraeus wrote: > On Mon, Sep 23, 2013 at 09:45:46AM -0400, Chris Lambacher wrote: > > [...] The exact use case is in Django templates where a value comes > > from the database. If you want to compare you either have to use > > __class__ which I would say is a

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Ethan Furman
On 09/23/2013 08:16 AM, Steven D'Aprano wrote: I would expect instance.blue to work, and I'm completely at a loss as to how Enum has managed to prevent it. [A peek behind the curtains...] Currently, Enum members do not live in the class dict. So when, for example, blue is searched for in red

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Guido van Rossum
On Mon, Sep 23, 2013 at 8:16 AM, Steven D'Aprano wrote: > On Mon, Sep 23, 2013 at 07:53:00AM -0700, Guido van Rossum wrote: > > > there is no rule that because you can > > access something on the class you should be able to access it on the > > instance. Try asking an instance for its class's __mr

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Guido van Rossum
On Mon, Sep 23, 2013 at 6:45 AM, Chris Lambacher wrote: > > On Sun, Sep 22, 2013 at 10:41 PM, Zero Piraeus wrote: > >> I may be misunderstanding the use case given in the issue, >> > > To clarify the use case, since it is my bug, this is so that the enum > values are always available for comparis

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Steven D'Aprano
On Mon, Sep 23, 2013 at 07:53:00AM -0700, Guido van Rossum wrote: > there is no rule that because you can > access something on the class you should be able to access it on the > instance. Try asking an instance for its class's __mro__ or __bases__. It might not be a rule, but it's certainly the

Re: [Python-Dev] Enum Eccentricities

2013-09-23 Thread Chris Lambacher
On Sun, Sep 22, 2013 at 10:41 PM, Zero Piraeus wrote: > I may be misunderstanding the use case given in the issue, > To clarify the use case, since it is my bug, this is so that the enum values are always available for comparison. The exact use case is in Django templates where a value comes fro

Re: [Python-Dev] Enum Eccentricities

2013-09-22 Thread Guido van Rossum
On Sunday, September 22, 2013, Zero Piraeus wrote: > I may be misunderstanding the use case given in the issue, but it seems > to me that having to use > > Color.red.__class__.blue > > (what is being complained about in the issue), while not exactly pretty, > makes a lot more semantic sense th

Re: [Python-Dev] Enum Eccentricities

2013-09-22 Thread Zero Piraeus
: On Sun, Sep 22, 2013 at 04:52:36PM -0700, Ethan Furman wrote: > So, as anyone who has worked with Enum is probably aware by now, > Enum's are a strange duck -- you might even call them platypuses. Yes :-) > What I'm looking for feedback on is the question is #19011: should an > Enum member be

Re: [Python-Dev] Enum Eccentricities

2013-09-22 Thread Greg Ewing
Ethan Furman wrote: Also, if we change Enum so that members do act more like class attributes, then things like Color.red.blue.green.blue will result in Color.blue, I thought we already decided it was worth making that not happen? -- Greg ___ Python

Re: [Python-Dev] Enum Eccentricities

2013-09-22 Thread Guido van Rossum
On Sun, Sep 22, 2013 at 4:52 PM, Ethan Furman wrote: > http://bugs.python.org/**issue19011 > > So, as anyone who has worked with Enum is probably aware by now, Enum's > are a strange duck -- you might even call them platypuses. > > For example, Enum members are

[Python-Dev] Enum Eccentricities

2013-09-22 Thread Ethan Furman
http://bugs.python.org/issue19011 So, as anyone who has worked with Enum is probably aware by now, Enum's are a strange duck -- you might even call them platypuses. For example, Enum members are instances of the class, but they are defined inside the class structure, and new ones cannot be cr