Style question - defining immutable class data members

Matthew Woodcraft matthew at woodcraft.me.uk
Sun Mar 15 16:58:16 EDT 2009


"Rhodri James" <rhodri at wildebst.demon.co.uk> writes:

> But do you, though?  The only occasion I can think of that I'd want
> the search to go past the instance is this "auto-initialisation",
> and frankly I'd rather do that in an __init__ anyway.  Perhaps
> static methods or class methods work that way, I don't know how
> the innards of the interpreter handle that.
>
> Is there any actual advantage to self.attribute picking up
> Class.attribute instead of raising a NameError?

You use that any time you call an ordinary method using syntax like
'self.foo()'.

-M-



More information about the Python-list mailing list