2013/4/26 Nick Coghlan ncogh...@gmail.com
On Fri, Apr 26, 2013 at 8:29 AM, Barry Warsaw ba...@python.org wrote:
On Apr 25, 2013, at 03:19 PM, Guido van Rossum wrote:
Clearly this is a trick question. :-)
A bit, yes. :)
I was told when this was brought up previously (a week ago?) that
On 04/25/2013 10:30 PM, Nick Coghlan wrote:
Alternatively, we can flip it around and require that each enum
definition nominate an expected value type (defaulting to int) and
only convert class attributes that are instances of that type to
instances of the enum class.
I think this option
On Thu, 25 Apr 2013 16:09:41 -0700
Ethan Furman et...@stoneleaf.us wrote:
We just fixed NoneType() to return None instead of raising an exception.
Another use-case for calling NoneType is working with ORMs:
result = []
for field in row:
type = get_type(field) # returns int,
On Fri, Apr 26, 2013 at 1:09 AM, Ethan Furman et...@stoneleaf.us wrote:
We just fixed NoneType() to return None instead of raising an exception.
Another use-case for calling NoneType is working with ORMs:
result = []
for field in row:
type = get_type(field) # returns int, bool,
Steven D'Aprano wrote:
I don't think iscallable will work, since that descriptors like
staticmethod and classmethod aren't callable. Nor are properties.
Hmmm, maybe we should look for a __get__ method as
well? Enums of descriptors would seem to fall into
the seriously-weird category as well.
Piotr Duda wrote:
There is at least one more problem, enum inheritance, given:
class Colors(Enum):
red = 1
green = 2
blue = 3
class MoreColors(Color):
cyan = 4
magenta = 5
yellow = 6
what type is MoreColors.red?
Given the implementation we're considering, it would
probably be
26.04.13 11:00, Greg Ewing написав(ла):
However, there's a worse problem with defining enum
inheritance that way. The subtype relation for extensible
enums works the opposite way to that of classes.
To see this, imagine a function expecting something
of type Colors. It knows what to do with
On 26/04/13 18:00, Greg Ewing wrote:
However, there's a worse problem with defining enum
inheritance that way. The subtype relation for extensible
enums works the opposite way to that of classes.
To see this, imagine a function expecting something
of type Colors. It knows what to do with red,
On 26/04/2013 06:21, Ethan Furman wrote:
On 04/25/2013 08:14 PM, Greg wrote:
On 26/04/2013 1:28 p.m., Ethan Furman wrote:
Interesting idea, but why does Day(3) have to be disallowed to make it
work?
Because it's ambiguous. Which day of the week is number 3? It
depends on where you start.
On 04/26/2013 12:34 AM, Greg Ewing wrote:
Or if, as Guido says, the only sensible things to use
as enum values are ints and strings, just leave anything
alone that isn't one of those.
The standard Java documentation on enums:
http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
ACTIVITY SUMMARY (2013-04-19 - 2013-04-26)
Python tracker at http://bugs.python.org/
To view or respond to any of the issues listed below, click on the issue.
Do NOT respond to this message.
Issues counts and deltas:
open3949 (+21)
closed 25674 (+32)
total 29623 (+53)
Open issues
26.04.13 18:50, Larry Hastings написав(ла):
On 04/26/2013 12:34 AM, Greg Ewing wrote:
Or if, as Guido says, the only sensible things to use
as enum values are ints and strings, just leave anything
alone that isn't one of those.
The standard Java documentation on enums:
On 04/26/2013 08:50 AM, Larry Hastings wrote:
FWIW I'm +0.5 on the enum metaclass ignores callables and
descriptors. This seems reasonably Pythonic, much more so than ignore
everything except ints and strings. And as long as we're
special-casing it I think we should opt for flexibility.
On Fri, Apr 26, 2013 at 10:33 AM, Glenn Linderman v+pyt...@g.nevcal.com wrote:
On 4/25/2013 9:19 PM, Guido van Rossum wrote:
On Thu, Apr 25, 2013 at 8:39 PM, Glenn Linderman v+pyt...@g.nevcal.com
wrote:
an enumeration of objects whose class defines __call__ would
not be so weird.
On 04/26/2013 09:27 AM, Serhiy Storchaka wrote:
26.04.13 18:50, Larry Hastings написав(ла):
The standard Java documentation on enums:
http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
This example requires more than features discussed here. It requires
an enum constructor.
On 04/26/2013 09:27 AM, Serhiy Storchaka wrote:
26.04.13 18:50, Larry Hastings написав(ла):
On 04/26/2013 12:34 AM, Greg Ewing wrote:
Or if, as Guido says, the only sensible things to use
as enum values are ints and strings, just leave anything
alone that isn't one of those.
The standard
On 4/25/2013 9:19 PM, Guido van Rossum wrote:
On Thu, Apr 25, 2013 at 8:39 PM, Glenn Linderman v+pyt...@g.nevcal.com wrote:
an enumeration of objects whose class defines __call__ would
not be so weird.
Seriously? You'd complexificate the basic usage in order to cater for
such an esoteric use
On Fri, Apr 26, 2013 at 10:36 AM, Guido van Rossum gu...@python.org wrote:
On Fri, Apr 26, 2013 at 10:33 AM, Glenn Linderman v+pyt...@g.nevcal.com
wrote:
On 4/25/2013 9:19 PM, Guido van Rossum wrote:
On Thu, Apr 25, 2013 at 8:39 PM, Glenn Linderman v+pyt...@g.nevcal.com
wrote:
an
26.04.13 11:00, Greg Ewing написав(ла):
However, there's a worse problem with defining enum
inheritance that way. The subtype relation for extensible
enums works the opposite way to that of classes.
To see this, imagine a function expecting something
of type Colors. It knows what to do with
26.04.13 05:13, Nick Coghlan написав(ла):
With a merged design, it becomes *really* hard to give the instances
custom behaviour, because the metaclass will somehow have to
differentiate between namespace entries that are intended to be
callables, and those which are intended to be instances of
Thank you for your answers, Barry. Eli already answered me most of my
questions.
20.04.13 22:18, Barry Warsaw написав(ла):
On Apr 13, 2013, at 11:31 AM, Serhiy Storchaka wrote:
The str and repr of the enumeration class also provides useful information::
print(Colors)
Colors
On Fri, Apr 26, 2013 at 11:17 AM, Eli Bendersky eli...@gmail.com wrote:
On Fri, Apr 26, 2013 at 10:36 AM, Guido van Rossum gu...@python.org wrote:
On 4/25/2013 9:19 PM, Guido van Rossum wrote:
I think you've lost track of the Zen of Python.
I feel that this thread has lost track of it long
Hello,
I have proposed a new generator finalization scheme in
http://bugs.python.org/issue17807: it removes the tp_del from
generator objects, instead electing to cleanup the generator
(equivalent of calling close()) in the frame's tp_clean function. This
way, generators with a try / finally
On Fri, Apr 26, 2013 at 2:41 PM, Guido van Rossum gu...@python.org wrote:
On Fri, Apr 26, 2013 at 11:17 AM, Eli Bendersky eli...@gmail.com wrote:
On Fri, Apr 26, 2013 at 10:36 AM, Guido van Rossum gu...@python.org
wrote:
On 4/25/2013 9:19 PM, Guido van Rossum wrote:
I think you've lost
Guido van Rossum wrote:
If we had access to the syntax used for the definition, this would be
simple: assignments define items, def statements define methods. But
at run time we only see the final object resulting from the
definition,
Another way we could tell the difference is if the def
Eli Bendersky wrote:
There's a conceptual
difference between a value of an enumeration and a collection of such
values.
Not if you think of an enum as a type and a type as
defining a set of values. From that point of view, the
enum itself is already a collection of values, and
introducing
On 4/26/2013 6:22 PM, Greg Ewing wrote:
Guido van Rossum wrote:
If we had access to the syntax used for the definition, this would be
simple: assignments define items, def statements define methods. But
at run time we only see the final object resulting from the
definition,
Another way we
On 04/26/2013 06:37 PM, Greg Ewing wrote:
Eli Bendersky wrote:
There's a conceptual difference between a value of an enumeration and a
collection of such values.
Not if you think of an enum as a type and a type as
defining a set of values. From that point of view, the
enum itself is already
On 04/26/2013 11:17 AM, Eli Bendersky wrote:
I feel that this thread has lost track of it long ago. Some time back in the
Enum discussions (some 350 messages ago or
so), there was a proposal to have this:
class Color(Enum):
RED, BLUE, GREEN
By doing some crazy-cool shenanigans. Although
Guido van Rossum gu...@python.org writes:
On Monday, April 15, 2013, Nikolaus Rath wrote:
Brian Curtin br...@python.org javascript:; writes:
On Fri, Apr 12, 2013 at 12:04 AM, Nikolaus Rath
nikol...@rath.orgjavascript:;
wrote:
[ Note: I already asked this on
Steven D'Aprano st...@pearwood.info writes:
On 26/04/13 13:22, Greg wrote:
On 26/04/2013 3:12 p.m., Glenn Linderman wrote:
On 4/25/2013 7:49 PM, Nick Coghlan wrote:
You couldn't create an enum of callables, but that would be a
seriously weird thing to do anyway
But aren't all classes
There are no guarantees in life. On the other hand: Don't worry, be happy.
On Fri, Apr 26, 2013 at 7:39 PM, Nikolaus Rath nikol...@rath.org wrote:
Guido van Rossum gu...@python.org writes:
On Monday, April 15, 2013, Nikolaus Rath wrote:
Brian Curtin br...@python.org javascript:; writes:
On
On 04/26/2013 07:29 PM, Glenn Linderman wrote:
On 4/26/2013 6:22 PM, Greg Ewing wrote:
Guido van Rossum wrote:
If we had access to the syntax used for the definition, this would be
simple: assignments define items, def statements define methods. But
at run time we only see the final object
33 matches
Mail list logo