[omaha] February meeting 2014

Jeff Hinrichs - DM&T jeffh at dundeemt.com
Wed Feb 19 01:22:18 CET 2014


Crazy busy time of the year, so I won't be able to attend.  But I offer
this snippet to take a dict and return a dot accessible object from it.
http://www.blog.pythonlibrary.org/2014/02/14/python-101-how-to-change-a-dict-into-a-class/


class Dict2Obj(object):
    """
    Turns a dictionary into a class
    """

    #----------------------------------------------------------------------
    def __init__(self, dictionary):
        """Constructor"""
        for key in dictionary:
            setattr(self, key, dictionary[key])

    #----------------------------------------------------------------------
    def __repr__(self):
        """"""
        attrs = str([x for x in dir(self) if "__" not in x])

        return "<Dict2Obj: %s>" % attrs
 #----------------------------------------------------------------------if
__name__ == "__main__":
    ball_dict = {"color":"blue",
                 "size":"8 inches",
                 "material":"rubber"}
    ball = Dict2Obj(ball_dict)


Not needed normally, but once in a while, it's just the ticket.


On Mon, Feb 17, 2014 at 1:35 PM, Jay Hannah <jay at jays.net> wrote:

> On Feb 17, 2014, at 1:25 PM, Steve Young <wereapwhatwesow at gmail.com>
> wrote:
> > This is a sad day for Omaha Python... We are less interesting than a CERT
> > meeting.  I will buy a round if someone comes up with topic/idea/location
> > for this month's meeting that will entice Joe to change his mind!
>
> OMG!Code needs presenter(s) for March 25 7pm. Would anyone be willing
> present whatever Python stuff they're excited about?
>
>    http://omacode.org
>
> Thanks,
>
> j
>
>
>
>
> _______________________________________________
> Omaha Python Users Group mailing list
> Omaha at python.org
> https://mail.python.org/mailman/listinfo/omaha
> http://www.OmahaPython.org
>



-- 
Best,

Jeff Hinrichs
402.218.1473


More information about the Omaha mailing list