This code keeps giving me the error:
TypeError: 'NoneType' object has no attribute 'getitem'
class d_exposure(object):
def __init__(self):
self.files = glob.glob('C:\files')
def exposure(self,level):
level = inspect.getargspec(d_exposure().exposure)[3][0]
print level
def main():
mp = d_exposure()
mp.exposure(level = 'MID')
It seems that the problem is that it wants a default value for level. However, the traceback shows it is getting a value.
Traceback (most recent call last):
File "C:\Users\Documents\my_scripts\exposure.py", line 58, in <module>
main()
File "C:\Users\Documents\my_scripts\exposure.py", line 54, in main
mp.exposure(level = 'MID')
File "C:\Users\Documents\my_scripts\exposure.py", line 17, in exposure
level = inspect.getargspec(d_exposure().exposure)[3][0]
When I try giving it a default value 'DIM', then the output has 'DIM', even though the call I made was mp.exposure(level = 'MID'). Can someone please help me figure out what I'm doing wrong?
level, just use it directly. There's no need for any introspection. Are you prehaps confusing the syntax for passing a keyword argument for the syntax declaring a default argument value?inspect.getargspec, I suspect it would do what you want. If you wantlevelto be an optional argument, you can usedef exposure(self, level="DIM"):.