Python is wierd!
Rainer Deyke
root at rainerdeyke.com
Wed Jul 26 02:37:59 EDT 2000
"Christian Tanzer" <tanzer at swing.co.at> wrote in message
news:m13HJaf-000wcDC at swing.co.at...
>"Rainer Deyke" <root at rainerdeyke.com> wrote:
>> 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.
>
>That's a strong statement. But it is not true.
>
>If you write code using classes as first-class objects, class
>variables and methods can be very useful.
If you need an object that acts like a class with added features, you can
write a wrapper around the class.
class class_with_extra:
def __init__(self, it, **extras):
self.__dict__.update(extras)
self.it = it
def __getattr__(self, name):
return getattr(self.it, name)
--
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