def _getDisplayableArguments(obj, alwaysShow, fieldNames):
 displayableArgs = []
 if _PY3:
  signature = inspect.signature(obj.__class__.__init__)
  for name in fieldNames:
   defaultValue = signature.parameters[name].default
   fieldValue = getattr(obj, name, defaultValue)
   if ((name in alwaysShow) or (fieldValue != defaultValue)):
    displayableArgs.append((' %s=%r' % (name, fieldValue)))
 else:
  argspec = inspect.getargspec(obj.__class__.__init__)
  defaults = dict(zip(reversed(argspec.args), reversed(argspec.defaults)))
  for name in fieldNames:
   defaultValue = defaults.get(name)
   fieldValue = getattr(obj, name, defaultValue)
   if ((name in alwaysShow) or (fieldValue != defaultValue)):
    displayableArgs.append((' %s=%r' % (name, fieldValue)))
 return displayableArgs

def _getDisplayableArguments ( obj , alwaysShow , fieldNames ) : displayableArgs = [ ] if _PY3 : signature = inspect . signature ( obj . __class__ . __init__ ) for name in fieldNames : defaultValue = signature . parameters [ name ] . default fieldValue = getattr ( obj , name , defaultValue ) if ( ( name in alwaysShow ) or ( fieldValue != defaultValue ) ) : displayableArgs . append ( ( ' %s=%r' % ( name , fieldValue ) ) ) else : argspec = inspect . getargspec ( obj . __class__ . __init__ ) defaults = dict ( zip ( reversed ( argspec . args ) , reversed ( argspec . defaults ) ) ) for name in fieldNames : defaultValue = defaults . get ( name ) fieldValue = getattr ( obj , name , defaultValue ) if ( ( name in alwaysShow ) or ( fieldValue != defaultValue ) ) : displayableArgs . append ( ( ' %s=%r' % ( name , fieldValue ) ) ) return displayableArgs
inspect the function signature of c{obj}s constructor .