Created
March 16, 2015 13:31
-
-
Save kracekumar/17c511662efbbb5df85a to your computer and use it in GitHub Desktop.
getattr doesn't take keyword arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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