Re: [Tutor] class arguments?

2009-01-23 Thread Kent Johnson
Forwarding to the list with my reply... On Fri, Jan 23, 2009 at 1:35 PM, spir wrote: > Le Fri, 23 Jan 2009 06:45:04 -0500, > Kent Johnson a écrit : > >> On Fri, Jan 23, 2009 at 6:04 AM, spir wrote: >> >> > Thank you Alan and sorry for not having been clear enough. The point >> > actually was c

Re: [Tutor] class arguments?

2009-01-23 Thread Kent Johnson
On Fri, Jan 23, 2009 at 6:04 AM, spir wrote: > Thank you Alan and sorry for not having been clear enough. The point actually > was class (definition) attributes. I thought at e.g. Guido's views that lists > were for homogeneous sequences as opposed to tuples rather like records. And > a way to

Re: [Tutor] class arguments?

2009-01-23 Thread spir
Le Thu, 22 Jan 2009 23:29:59 -, "Alan Gauld" a écrit : > > "Alan Gauld" 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

Re: [Tutor] class arguments?

2009-01-22 Thread Alan Gauld
"Alan Gauld" 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

Re: [Tutor] class arguments?

2009-01-22 Thread Kent Johnson
On Thu, Jan 22, 2009 at 5:18 PM, Kent Johnson wrote: > On Thu, Jan 22, 2009 at 4:51 PM, spir wrote: >> Hello, >> >> is there a way to give arguments to a class definition? Eg >> >> class MonoList(list, typ, number): >>item_type = typ >>item_number = number > > Use the type() funct

Re: [Tutor] class arguments?

2009-01-22 Thread Kent Johnson
On Thu, Jan 22, 2009 at 4:51 PM, spir wrote: > Hello, > > is there a way to give arguments to a class definition? Eg > > class MonoList(list, typ, number): >item_type = typ >item_number = number Use the type() function (which is the constructor for the type 'type') to dynamically

Re: [Tutor] class arguments?

2009-01-22 Thread Alan Gauld
"spir" wrote is there a way to give arguments to a class definition? Eg class MonoList(list, typ, number): item_type = typ item_number = number Yes thats what the __init__ method is for. class MonoList: def __init__(self, lst, typ, num): self.item_type = typ self.number = num