Re: Adding attributes stored in a list to a class dynamically.

2007-09-03 Thread Brian Munroe
On Sep 3, 6:34 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > The underscore versions are for customizing the lookup process, not for > dynamically looking up names. If your class needs to do something non- > standard when you write obj.name, you might need to write methods >

Re: Adding attributes stored in a list to a class dynamically.

2007-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2007 04:37:54 +, Brian Munroe wrote: > On Sep 2, 3:33 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: > > >> In a nutshell, like all double-underscore methods, __setattr__ are for >> overriding behaviour in your own classes. With very few exceptions, you >>

Re: Adding attributes stored in a list to a class dynamically.

2007-09-03 Thread Bruno Desthuilliers
Brian Munroe a écrit : > On Sep 2, 3:33 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: > >> In a nutshell, like all double-underscore methods, __setattr__ are for >> overriding behaviour in your own classes. With very few exceptions, you >> shouldn't need to directly call doub

Re: Adding attributes stored in a list to a class dynamically.

2007-09-02 Thread Brian Munroe
On Sep 2, 3:33 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > > In a nutshell, like all double-underscore methods, __setattr__ are for > overriding behaviour in your own classes. With very few exceptions, you > shouldn't need to directly call double-underscore methods (althoug

Re: Adding attributes stored in a list to a class dynamically.

2007-09-02 Thread Steven D'Aprano
On Sun, 02 Sep 2007 21:41:43 +, Brian Munroe wrote: > One question though, which I haven't been able to find the answer from > scouring the internet. What is the difference between calling > __setattr__ and setattr or __getattr__ and getattr, for that matter? Have you read the following? #

Re: Adding attributes stored in a list to a class dynamically.

2007-09-02 Thread Brian Munroe
On Sep 2, 11:46 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > If you want to pass the attributes list it's simpler to do that > directly, avoiding *a and **k constructs. E.g.: > > def __init__(self, a, b, attrs): > self.a = a > self.b = b > for attr in attrs: > name, value =

Re: Adding attributes stored in a list to a class dynamically.

2007-09-02 Thread Alex Martelli
Nathan Harmston <[EMAIL PROTECTED]> wrote: > Hi, > > Sorry if the subject line of post is wrong, but I think that is what > this is called. I want to create objects with > > class Coconuts(object): > def __init__(self, a, b, *args, **kwargs): > self.a = a > self.b = b > > def sp

Adding attributes stored in a list to a class dynamically.

2007-09-02 Thread Nathan Harmston
Hi, Sorry if the subject line of post is wrong, but I think that is what this is called. I want to create objects with class Coconuts(object): def __init__(self, a, b, *args, **kwargs): self.a = a self.b = b def spam( l ) return Coconuts( l.a, l.b, l.attributes ) l in a parse