Class initialization

Costin Gament costin.gament at gmail.com
Sun Aug 8 17:14:06 CEST 2010


So you're saying I should just use __init__? Will that get me out of
my predicament?
No, I don't quite understand the difference between my exemple and
using __init__, but I will read the docs about it.

On Sun, Aug 8, 2010 at 6:01 PM, Tim Harig <usernet at ilthio.net> wrote:
>
> Others have told you that at a and b belong to the class object rather then
> to the instance objects.  Perhaps this will demonstrate the difference:
>
>>>> class foo():
> ...     def __init__(self):
> ...             self.a = 0
> ...             self.b = 0
> ...
>>>> c1 = foo()
>>>> c1.a = 5
>>>> c2 = foo()
>>>> print c2.a
> 0
>>>>



More information about the Python-list mailing list