Re: - Copy dictionary entries to attributes

2006-02-21 Thread Ilias Lazaridis
Alex Martelli wrote: > Ben Wilson <[EMAIL PROTECTED]> wrote: > >> Perhaps: >> >> def dictionary_make_attributes(self, settings): >> for k,v in settings: >> setattr(self, k, v) for k,v in settings.items() > This is a very general solution and will work for all kinds of objects > wit

Re: - Copy dictionary entries to attributes

2006-02-21 Thread Ilias Lazaridis
Ben Wilson wrote: > Perhaps: > > def dictionary_make_attributes(self, settings): > for k,v in settings: > setattr(self, k, v) this one resulted in an error: "ValueError: too many values to unpack" it works with this correction: for k,v in settings.items() > http://ftp.python.org

Re: [DICTIONARY] - Copy dictionary entries to attributes

2006-02-21 Thread Ilias Lazaridis
Diez B. Roggisch wrote: > Ilias Lazaridis schrieb: >> remark: not sure if the term "dictionary" is correct here. >> >> I have the following situation: >> >> within a setup.cfg, settings are passed this way: >> >> settings=project_page=theProjectPage.com >> myVar=myValue >> >> those are acce

Re: - Copy dictionary entries to attributes

2006-02-18 Thread Alex Martelli
Ben Wilson <[EMAIL PROTECTED]> wrote: > Perhaps: > > def dictionary_make_attributes(self, settings): > for k,v in settings: > setattr(self, k, v) This is a very general solution and will work for all kinds of objects with settable attributes, even if some of the attributes are prop

Re: - Copy dictionary entries to attributes

2006-02-18 Thread Ben Wilson
Perhaps: def dictionary_make_attributes(self, settings): for k,v in settings: setattr(self, k, v) http://ftp.python.org/doc/lib/built-in-funcs.html#l2h-64 -- http://mail.python.org/mailman/listinfo/python-list

Re: [DICTIONARY] - Copy dictionary entries to attributes

2006-02-18 Thread Diez B. Roggisch
Ilias Lazaridis schrieb: > remark: not sure if the term "dictionary" is correct here. > > I have the following situation: > > within a setup.cfg, settings are passed this way: > > settings=project_page=theProjectPage.com > myVar=myValue > > those are accessible later like this: > > set

[DICTIONARY] - Copy dictionary entries to attributes

2006-02-18 Thread Ilias Lazaridis
remark: not sure if the term "dictionary" is correct here. I have the following situation: within a setup.cfg, settings are passed this way: settings=project_page=theProjectPage.com myVar=myValue those are accessible later like this: settings['project_page'] / settings['myValue'] -