#87 when variables are found, use introspection to see if it's a

Epytext (19)


would it be possible that when variables are found, use introspection to see if it's a real variable or a function reference (by using hasattr(var, "__call__") )? If it is a function ref, then treat it like a function and use it's __doc__. This would be nice since I (and probably others :-), I know Twisted does) use functools.partial and/or closures to define fuction aliases and/or functions that call another "private" and more generalized function and feed it internal params that way the end user does not need to worry about it ("currying"). Here are some examples :

From Twisted (twisted.trial.unittest._Assertions):

def failUnless(self, condition, msg=None):
"""fails the test if C{condition} evaluates to True

@param condition: any object that defines __nonzero__
if not condition:
raise self.failureException(msg)
return condition
assert_ = assertTrue = failUnlessTrue = failUnless

and from me :

def __createRegAndUpMsgBody(msgType, serviceName, serviceVersion,
Nice epytext here .....
# ...
# ...
return regRoot

# Create a function of the service registeration and update using function
# currying (partial function in python)
createRegUpMsgBody = functools.partial(__createRegAndUpMsgBody, constants.UPDATE_REG_MSG_TYPE)
createRegMsgBody = functools.partial(__createRegAndUpMsgBody, constants.REG_MSG_TYPE)

Please tell me what you think, thanks


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks