Looks like I have the attribute of 'dlist0' with the object 'row_id' as I
<then this value returns again but if I have a dictionary
ddict0 = { 'Row_id': 4, 'name': 'account_balance'} getattr (ddict0, 'row_id') this is not work
My question is how do I Ddict0 and dlist0
dictionaries contain items, and use them as < / P>
Ob There are properties of objects, and use __getattr __ () to use this type, which is defined as __getitem __ () Of a specialty.
You can theoretically override to point to another, if you need it - but why do you need it? Why not just write a supporting function:
Python 2.x:
def get_value (some_thing, some_key): if (some '' tubal ',' list ') Back to something something [some_key] Second: return getattr (some_thing, some_key) Python 3.x:
def Get_value (some_thing, some_key): If the type (some, some, something) (dict, tuple, list): some_thing [some_key] Return: return getattr (some_thing, some_key)
Comments
Post a Comment