Python is wierd!

Rainer Deyke root at rainerdeyke.com
Fri Jul 28 21:31:07 EDT 2000


"Vespe Savikko" <vespe at cs.tut.fi> wrote in message
news:vph8zun26wx.fsf at hiirihaukka.cs.tut.fi...
> Also sprach "Rainer Deyke" <root at rainerdeyke.com>:
>
>   Static variables and methods are a mess anyway.  In Python, there is
>   no need for them - just place the variables and functions outside
>   the class.  In Java, they are a (poor) substitite for placing things
>   outside the class.  In C++, static class members are sometimes
>   useful for access control and templates, both of which have no place
>   in Python.
>
> I think you are being too hard on static variables. The class
> attributes have their uses in Python as well. For example, since class
> attribute becomes a part of the class.__dict__, you can later define
> that same attribute in the subclasses as well, and still can retain
> the access to the 'same' class attribute in the superclass. In other
> words the value of the class attribute can be seen to as accumulating
> knowledge: besides its own class attribute a subclass instance can
> query the value of the class attribute of the base class as well.

Let me clarify my position: static variables/methods in Java/C++ are a mess
(although still sometimes useful, especially with templates).  Class
attributes in Python are elegant and useful in ways that static variables in
Java and C++ aren't (although get_? functions could often serve the same
purpose).


--
Rainer Deyke (root at rainerdeyke.com)
Shareware action/role-playing games      -      http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list