Message184498
This might be a duplicate of issue17053, but the patch provided there doesn't resolve the issue, at least as far as I know it. Here is an example, from David Beazley's talk at PyCon 2013:
from inspect import Parameter, Signature
def make_signature(names):
return Signature(
Parameter(name, Parameter.POSITIONAL_OR_KEYWORD) for name in names)
class Structure:
__signature__ = make_signature([])
def __init__(self, *args, **kwargs):
bound = self.__signature__.bind(*args, **kwargs)
for name, val in bound.arguments.items():
setattr(self, name, val)
class Stock(Structure):
__signature__ = make_signature(['name', 'shares', 'price'])
pyth = Stock('PYTH', 100, 50)
help(pyth.__init__)
Which produces:
__init__(self, *args, **kwargs) method of __main__.Stock instance
Instead of:
__init__(self, name, shares, price) method of __main__.Stock instance |
|
Date |
User |
Action |
Args |
2013-03-18 19:28:28 | jafo | set | recipients:
+ jafo |
2013-03-18 19:28:28 | jafo | set | messageid: <1363634908.24.0.328238264763.issue17424@psf.upfronthosting.co.za> |
2013-03-18 19:28:28 | jafo | link | issue17424 messages |
2013-03-18 19:28:27 | jafo | create | |
|