Sean Reifschneider added the comment:

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

----------
type:  -> behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17424>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to