Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

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

v3.0
open
Edward Loper
Epytext (19)
5
2008-06-13
2008-06-13
Gabriel Rossetti
No

Hello,

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,
serviceAcceptedMsgs):
"""
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
Gabriel

Discussion