Data attributes...

Lawrence Oluyede rhymes at myself.com
Thu Jan 24 12:56:58 EST 2002


I've just read about data attributes.

The tut says:

"Data attributes need not be declared; like local variables, they
spring into existence when they are first assigned to"

Why that? I think it could be illegal...

see the ex:

class MyClass:
    "A simple example class"
    i = 12345
    
    def f(self):
        return 'hello world'

x = MyClass()

x.counter = 1
while x.counter < 10:
    x.counter = x.counter * 2
print x.counter
del x.counter

it prints 16

but the question is...why?? With this feature i could make my sources
hard to read and so confused i think...

-- 
Lawrence "Rhymes" Oluyede (rhymes at myself.com)
"Per cambiare, per diventare un'altra
cosa dobbiamo prima sapere cosa siamo"
(Bruce Lee)



More information about the Python-list mailing list