Really stupid question regarding PEP 252 and type/class unification

Alex Martelli aleax at
Thu Aug 23 16:33:25 CEST 2001

"Russell Turpin" <russell_turpin at> wrote in message
news:8a12e538.0108230607.30481024 at
>     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


> 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:-).


More information about the Python-list mailing list