Éric Daigneault lists wrote:

> When creating a class with data members but no __init__ method.  Python 
> deals differently with data members that are muatable and immutables.

no, it doesn't.  it's your code that deals with them in different ways, 
not Python.

> Ex:
> class A(object):
>     stringData = "Whatever"
>     listData = []
> 
> instance = A()
> 
> Will have data members instantiated as expected (instance.stringData == 
> "Whatever" and instance.listData == [])
> 
> instance.listData.append("SomeString")

here, you call a method on the class object.  this method modifies the 
object.

> instance.stringData = "Changed"

here, you use assignment to *add* a new attribute to the instance.

the class attribute is still there, but it's shadowed by an instance 
attribute with the same name.

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to