Python variables are bound to types when used?

sjdevnull at yahoo.com sjdevnull at yahoo.com
Fri Oct 21 18:26:47 EDT 2005


Diez B. Roggisch wrote:
> sjdevnull at yahoo.com wrote:
> > Fredrik Lundh wrote:
> >
> >>reset your brain:
> >>
> >>    http://effbot.org/zone/python-objects.htm
> >
> >
> > Neat link.
> >
> > Can you expand on this:
> >
> >
> >>a type (returned by type(x))
> >
> > ...
> >
> >>You cannot change the type.
...
> So what? That the flexibility of python allows for such a hack has
> nothing to do with x being totally unaware of the type of the object it
> points to.

I'm still not understanding, maybe my question was unclear (and was
related to the writeup that was linked, I wasn't saying anything about
the relationships of names and objects).

I'm wondering what is meant by "you cannot change the type", and
whether I'm misunderstanding what is going on in my example when I say
"x.__class__=a".  It looks to me like the type of the object that "x"
is referencing changes, but the URL implies that something else might
actually be happening.  I'm not understanding the distinction.




More information about the Python-list mailing list