Xavier Ho wrote:
On Wed, Apr 21, 2010 at 7:59 AM, Alan Harris-Reid <aharrisr...@googlemail.com <mailto:aharrisr...@googlemail.com>> wrote:

    The code is not usually in class.__init__ (otherwise I would have
    used the self. prefix)


Alan, if your variables are not usually in __init__, what's preventing you from using class variables like this:

>>> class Test():
...     something = 1
...     more = 2
... >>> Test.more
2

What's your use case?

Cheers,
Xav
Hi Xavier, thanks for the reply,

In this case I am setting attributes of an instantiated class, so the original class might go something like

class Test
   attr1 = some default value
   attr2 = another default value
   attr3 = yet another default value
   etc.

and the instantiated class might go something like

Test2 = Test()
Test2.attr1 = runtime value
Test2.attr2 = another runtime value
etc.

Regards,
Alan




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

Reply via email to