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


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

Re: Modifying signature of ctor in class

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2015-09-24 17:31 -0600
Last post2015-09-24 17:31 -0600
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 Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-24 17:31 -0600

#97103 — Re: Modifying signature of ctor in class

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-09-24 17:31 -0600
SubjectRe: Modifying signature of ctor in class
Message-ID<mailman.154.1443137539.28679.python-list@python.org>
On Thu, Sep 24, 2015 at 5:01 PM, Joseph L. Casale
<jcasale@activenetwerx.com> wrote:
>> 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)
>
> That actually should harmlessly support Python versions less than 3.3
> while simply accomplishing nothing. I don't even need a test for the version.
>
> I'll go with that as a decent trade off.

Well, setting the __signature__ attribute is harmless, but do note
that inspect.Signature doesn't exist before 3.3.

[toc] | [standalone]


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


csiph-web