Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97100 > unrolled thread

Re: Modifying signature of ctor in class

Started byChris Angelico <rosuav@gmail.com>
First post2015-09-25 08:23 +1000
Last post2015-09-25 08:23 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Modifying signature of ctor in class Chris Angelico <rosuav@gmail.com> - 2015-09-25 08:23 +1000

#97100 — Re: Modifying signature of ctor in class

FromChris Angelico <rosuav@gmail.com>
Date2015-09-25 08:23 +1000
SubjectRe: Modifying signature of ctor in class
Message-ID<mailman.152.1443133395.28679.python-list@python.org>
On Fri, Sep 25, 2015 at 8:19 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> Quick and dirty example:
>
> py> from inspect import Signature, Parameter
> py> def foo(*args, **kwargs): pass
> ...
> py> foo.__signature__ = Signature([Parameter('x',
> Parameter.POSITIONAL_OR_KEYWORD), Parameter('y',
> Parameter.KEYWORD_ONLY)])
> py> help(foo)
> Help on function foo in module __main__:
>
> foo(x, *, y)

Okay, that's a LOT easier than the stuff I was playing around with :)

Of course, it still requires that inspect.signature be used.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web