/ Published in: Python
                    
                                        
This bit of code allows you to turn code that looks like this:
x = {'foo':1, 'bar':2 }
x['foo'] = 3
Into this:
x = dictclass( {'foo':1, 'bar':2 } )
x.foo = 3
                x = {'foo':1, 'bar':2 }
x['foo'] = 3
Into this:
x = dictclass( {'foo':1, 'bar':2 } )
x.foo = 3
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
class dictclass:
"""Takes a dictionary and uses it as its __dict__ member, effectively
making the dictionary supply the object's attributes."""
def __init__( self, d ):
self.__dict__ = d
Comments
 Subscribe to comments
                    Subscribe to comments
                
                