Re: which "dictionary with attribute-style access"?

2009-10-24 Thread Andreas Balogh
baloan wrote: On Oct 22, 6:34 am, "Gabriel Genellina" wrote: class AttrDict(dict): """A dict whose items can also be accessed as member variables.""" def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = self def copy(self):

Re: which "dictionary with attribute-style access"?

2009-10-22 Thread baloan
On Oct 22, 6:34 am, "Gabriel Genellina" wrote: > > class AttrDict(dict): > >      """A dict whose items can also be accessed as member variables.""" > >      def __init__(self, *args, **kwargs): > >          dict.__init__(self, *args, **kwargs) > >          self.__dict__ = self > > >      def copy

Re: which "dictionary with attribute-style access"?

2009-10-21 Thread Gabriel Genellina
En Wed, 21 Oct 2009 18:40:01 -0300, Andreas Balogh escribió: Gabriel, thanks for your hint. I've managed to create an implementation of an AttrDict passing Gabriels tests. Any more comments about the pythonicness of this implementation? class AttrDict(dict): """A dict whose items can

Re: which "dictionary with attribute-style access"?

2009-10-21 Thread Andreas Balogh
Gabriel, thanks for your hint. I've managed to create an implementation of an AttrDict passing Gabriels tests. Any more comments about the pythonicness of this implementation? class AttrDict(dict): """A dict whose items can also be accessed as member variables.""" def __init__(self, *ar

Re: which "dictionary with attribute-style access"?

2009-10-17 Thread Aahz
In article , Terry Reedy wrote: >Aahz wrote: >> In article , >> Andreas Balogh wrote: >>> >>> My question to the Python specialists: which one is the most correct? >>> Are there restrictions with regards to pickling or copy()? >>> Which one should I choose? >> >> What's your goal? I'd probabl

Re: which "dictionary with attribute-style access"?

2009-10-17 Thread Terry Reedy
Aahz wrote: In article , Andreas Balogh wrote: My question to the Python specialists: which one is the most correct? Are there restrictions with regards to pickling or copy()? Which one should I choose? What's your goal? I'd probably do the dirt simple myself: class AttrDict(dict): def

Re: which "dictionary with attribute-style access"?

2009-10-16 Thread Aahz
In article , Andreas Balogh wrote: > >My question to the Python specialists: which one is the most correct? >Are there restrictions with regards to pickling or copy()? >Which one should I choose? What's your goal? I'd probably do the dirt simple myself: class AttrDict(dict): def __getattr_

Re: which "dictionary with attribute-style access"?

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 16:58:35 -0300, Andreas Balogh escribió: googling I found several ways of implementing a "dictionary with attribute-style access". 1. ActiveState cookbook: http://code.activestate.com/recipes/473786/ 2. ActiveState cookbook: http://aspn.activestate.com/ASPN/Cookbook

Re: which "dictionary with attribute-style access"?

2009-10-12 Thread Rhodri James
On Mon, 12 Oct 2009 20:58:35 +0100, Andreas Balogh wrote: Hello, googling I found several ways of implementing a "dictionary with attribute-style access". 1. ActiveState cookbook: http://code.activestate.com/recipes/473786/ 2. ActiveState cookbook: http://aspn.activestate.com/ASPN/Coo

which "dictionary with attribute-style access"?

2009-10-12 Thread Andreas Balogh
Hello, googling I found several ways of implementing a "dictionary with attribute-style access". 1. ActiveState cookbook: http://code.activestate.com/recipes/473786/ 2. ActiveState cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361668 3. web2py codebase: Storage(dict) I