Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013年4月28日 23:42:26 -0700

Steven D'Aprano wrote:
On 29/04/13 10:29, Ethan Furman wrote:
 - bool(1) # True
 - int('11') # 11
 - str(var) # whatever var had in it, now as a str
I think that's a red herring, because you're comparing the use of the object constructor with look-up by name.
How does what bool() is doing differ from a lookup?
It's not constructing a new instance. Neither is
int() in the cases where the argument is in the
range of values that it caches.
More generally, the built-in types can be thought
of as coercion functions -- they take an argument
and return some related value from the type's
repertoire. Whether they do that by constructing
a new object or not is an implementation detail.
--
Greg
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to