How to get the 'name' of an int

Jp Calderone exarkun at intarweb.us
Fri Feb 28 11:18:17 EST 2003


On Fri, Feb 28, 2003 at 06:16:17AM -0800, Michele Simionato wrote:
> Just <just at xs4all.nl> wrote in message news:<just-779694.10462828022003 at news1.news.xs4all.nl>...
> > You need to "reset your brain":
> >   http://effbot.org/guides/python-objects.htm
> > 
> > HTH,
> > 
> > Just
> 
> 
> From the Effbot guide:
> 
>           Objects
> 
>           All Python objects have this:
> 
>                a unique identity (an integer, returned by id(x))
>                a type (returned by type(x))
>                some content
> 
>           You cannot change the identity.
> 
>           You cannot change the type.
>               ^^^^^^
> 
> However:
> 
> >>> class A(object): pass
> ...
> >>> class B(object): pass
> ...
> >>> a=A()
> >>> a.__class__=B
> >>> type(a)
> <class '__main__.B'>
> 
> Therefore I would say you "should" not change the type, but you can.
> 

  This is a recent change, as I'm sure you're aware, perhaps the Effbot's
guide needs to be updated, though not to should, but to "cannot always",
because as long as classic classes are around, there will be objects with
types that cannot be changed.

  Jp

--
http://catandgirl.com/view.cgi?44
-- 
 up 19 days, 20:29, 4 users, load average: 0.63, 0.29, 0.28
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030228/08799f3a/attachment.sig>


More information about the Python-list mailing list