On 01/21/2014 10:37 AM, Gary Oberbrunner wrote:
> So now it returns a python list of python dicts. All I want now is to
> override __getattr__ on each ppinfo dict so it returns the dict value
> as the attribute value, so in python I can reference
> effect_list[i].name instead of effect_list[i]['name']. Or any
> alternative way to get the same effect. Is that possible? 
There are many ways to do that elegantly in Python. For example:

class Effect:
  def __init__(self, mydict):
    self.__dict__.update(mydict)

If you want to combine that with existing classes / APIs, you could also
consider merging the new attributes in via metaclasses.

        Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to