[Python-Dev] enum discussion: can someone please summarize open issues?
greg.ewing at canterbury.ac.nz
Mon Apr 29 08:40:16 CEST 2013
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.
More information about the Python-Dev