Re: classes: need for an explanation

2007-01-18 Thread Steven D'Aprano
On Thu, 18 Jan 2007 03:58:22 -0800, 0k- wrote: > hello! > > i started to write a game in python in which i want to implement > "dynamically attachable" attributes. All attributes in Python are dynamically attachable. >>> class Parrot: ... pass ... >>> p = Parrot() >>> hasattr(p, "plumage")

Re: classes: need for an explanation

2007-01-18 Thread 0k-
thanks for the quick reply, Peter! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: classes: need for an explanation

2007-01-18 Thread Peter Otten
0k- wrote: > class Thing(object): > props = {} > def __init__(self): > self.props["text"] = TxtAttr("something important") > > t1 = Thing() > t2 = Thing() > > t2.props["text"].value = "another string" > > print "t1: %s\nt2: %s" % (t1.props["text"].value, > t2.props["text"].value

Re: classes: need for an explanation

2007-01-18 Thread 0k-
oops, i forgot to mention i'm using interpreter version 2.4.3 -- http://mail.python.org/mailman/listinfo/python-list

classes: need for an explanation

2007-01-18 Thread 0k-
hello! i started to write a game in python in which i want to implement "dynamically attachable" attributes. my intention is to generalise this and moreover these attributes can be complex, so i'm creating classes to represent these attributes. but somehow i cannot instantiate these attribute clas