Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Created March 16, 2015 13:31
Show Gist options
  • Save kracekumar/17c511662efbbb5df85a to your computer and use it in GitHub Desktop.
Save kracekumar/17c511662efbbb5df85a to your computer and use it in GitHub Desktop.
getattr doesn't take keyword arguments
In [1]: class Test:
...: def __init__(self):
...: self.a = 1
...:
In [2]: t = Test()
In [3]: getattr(object=t, name='a')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-058ca1abb59f> in <module>()
----> 1 getattr(object=t, name='a')
TypeError: getattr() takes no keyword arguments
In [4]: getattr(t, 'a')
Out[4]: 1
In [5]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment