D'Arcy J.M. Cain wrote:
> On Fri, 19 Jun 2009 13:17:24 -0500
> Amita Ekbote wrote:
> > I am retrieving values from a database in the form of a dictionary so
> > I can access the values as d['column'] and I was wondering if there is
> > a way to convert the hash to a struct like format so i can
Jason wrote:
> Here's my general-purpose solution for doing this:
>
> class Dict2Class(object):
> """
> Update like a dictionary, but expose the keys as class properties.
I'm afraid that's wrong. It's wrong twice:
* Properties are computed attributes. These are not, they are regular
att
Here's my general-purpose solution for doing this:
class Dict2Class(object):
"""
Update like a dictionary, but expose the keys as class properties.
Sweet!
You can instantiate and update this practically any way you
choose, and
the values are available as class properties.
>>> c
Amita Ekbote wrote:
I wanted to make a more generic way of doing this so that even if the
columns are modified or new ones are added it should be simple. Anyway
I will reconsider this sort of am implementation. Just out of
curiosity is there any other way of achieving this?
Thanks
Amita
On Fri,
I wanted to make a more generic way of doing this so that even if the
columns are modified or new ones are added it should be simple. Anyway
I will reconsider this sort of am implementation. Just out of
curiosity is there any other way of achieving this?
Thanks
Amita
On Fri, Jun 19, 2009 at 1:52
Amita Ekbote wrote:
> Hello,
>
> I am retrieving values from a database in the form of a dictionary so
> I can access the values as d['column'] and I was wondering if there is
> a way to convert the hash to a struct like format so i can just say
> d.column. Makes it easier to read and understand.
Amita Ekbote wrote:
> Hello,
>
> I am retrieving values from a database in the form of a dictionary so
> I can access the values as d['column'] and I was wondering if there is
> a way to convert the hash to a struct like format so i can just say
> d.column. Makes it easier to read and understand.
On Fri, 19 Jun 2009 13:17:24 -0500
Amita Ekbote wrote:
> I am retrieving values from a database in the form of a dictionary so
> I can access the values as d['column'] and I was wondering if there is
> a way to convert the hash to a struct like format so i can just say
> d.column. Makes it easier