"Alan Gauld" <[email protected]> wrote
is there a way to give arguments to a class definition?
I see that Kent interpreted your question differently to me.
If you do mean that you want to dynamically define class
attributes rather than instance attributes then __init__()
won't work. But I'd be interested to understand why and
how you would want to do that? And in particular how
you would use them after creating them?
Yes thats what the __init__ method is for.
class MonoList:
def __init__(self, lst, typ, num):
self.item_type = typ
self.number = num
etc...
myList = MonoList([1,2,3], int, 3) # or whatever...
Alan G.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor