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 accessible later like

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()

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 with settable

[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'] -

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:

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: - 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