Is there a cleaner way to get the defaults of a method than using the inspect module? I'd like to do this:
class C(object):
def __init__(self,Type='generic',X=5,Y=500):
defaults=getDefaults() #not sure about this line
typeDefaults_X={'short':'1','long':'10'}
typeDefaults_Y={'large':2000,'small':100}
if X == defaults['X']:
X = typeDefaults_X.get(Type, defaults['X'])
if Y == defaults['Y']:
Y = typeDefaults_Y.get(Type, defaults['Y'])
I know that I could do this by:
defaults=dict(zip(inspect.getargspec(C.__init__).args[1:],inspect.getargspec(C.__init__).defaults))
but it seems so terribly un-pythonic.
==instead ofis; for example note that100000+1 is 100000+1is False, but100+1 is 100+1is True.Typeparameter.