Really stupid question regarding PEP 252 and type/class unification
Alex Martelli
aleax at aleax.it
Thu Aug 23 10:33:25 EDT 2001
"Russell Turpin" <russell_turpin at hotmail.com> wrote in message
news:8a12e538.0108230607.30481024 at posting.google.com...
...
> class MyInt(type(0)):
> pass
>
> myInt = MyInt()
> myInt = 5 # Will this work?
Sure it will work: it re-binds name myInt to something
different just before, exactly as it always did. WHATEVER
myInt was before the
myInt = 5
has absolutely NO relevance.
> Now I type "myInt" into the interpreter. Does it print out:
>
> 5
Yes.
> Or does it print:
>
> <instance of MyInt>
Of course not. Just like:
class Whatever(anybase): pass
x = Whatever()
x = "nah, better be a string"
Now printing x will print
nah, better be a string
of course. Name x has been re-bound.
> Still-on-cold-med'ly yrs,
> Russell
Must be a pretty bad cold, Russell, or very interesting
medicine indeed:-).
Alex
More information about the Python-list
mailing list