learning python ...

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 25 18:48:34 EDT 2021


On 26/05/21 3:33 am, Dennis Lee Bieber wrote:
> the OBJECTS have a type and can not change type.

Well... built-in types can't, but...

 >>> class A:
...  pass
...
 >>> class B:
...  pass
...
 >>> a = A()
 >>> type(a)
<class '__main__.A'>
 >>> a.__class__ = B
 >>> type(a)
<class '__main__.B'>

-- 
Greg



More information about the Python-list mailing list