Really stupid question regarding PEP 252 and type/class unification
aleax at aleax.it
Thu Aug 23 16:33:25 CEST 2001
"Russell Turpin" <russell_turpin at hotmail.com> wrote in message
news:8a12e538.0108230607.30481024 at posting.google.com...
> class MyInt(type(0)):
> 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:
> 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,
Must be a pretty bad cold, Russell, or very interesting
More information about the Python-list