any ways to judge whether an object is initilized or not in a class

greg greg at cosc.canterbury.ac.nz
Tue Mar 20 02:12:23 CET 2007


Gabriel Genellina wrote:
> you may consider using a class 
> attribute as  a default value:
> 
> class Coffee:
> 
>     temp = 50

Be careful with that, though -- only use it for immutable
values. Doing that with a mutable object, such as a list,
will get you into trouble, since one object is being
shared between all instances.

--
Greg



More information about the Python-list mailing list