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


Groups > comp.lang.python > #97103

Re: Modifying signature of ctor in class

Path csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python': 0.10; 'def': 0.13; 'thu,': 0.15; '24,': 0.16; '3.3.': 0.16; 'decent': 0.16; 'subject:class': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'version.': 0.18; 'versions': 0.20; '2015': 0.20; 'parameter': 0.22; 'sep': 0.22; 'pass': 0.22; 'import': 0.24; 'header:In-Reply- To:1': 0.24; 'module': 0.25; "doesn't": 0.26; 'message- id:@mail.gmail.com': 0.27; 'function': 0.28; '**kwargs):': 0.29; 'inspect': 0.29; 'skip:_ 10': 0.32; 'foo': 0.33; "i'll": 0.33; 'received:google.com': 0.35; 'exist': 0.35; 'nothing.': 0.35; 'skip:p 30': 0.35; 'but': 0.36; 'should': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'setting': 0.37; 'skip:p 20': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=noit2D3FSkibiq9ryVY4aO9Cipm0J0ZA1ROB7N2dq+s=; b=IT7/mLRi30vbVAgau2xi6qdTlvaJ6wbHa+0BD93PqWhMpvMC9XF4MzqkXmLFVQD5UU rfnogGJ5UoJ/BOfuDsNe5MqhhXVY+8ujJjbI7Ne0gcZykkgZocEcMHDEMfPGiNPywIuS JebIrkLQRxdGPPSRNAuUX3oTISL+fwlkYJ+RmoVoWfvgbZ6JBa5VhxGNONkkB7kMugKX GzJdcCF9br3/NvWsPjEc9E6d9Z/J/UVOfNYKkXkvnhLoAa1dvTNvDSDmigDCtM5sHBfW R+aHrs6N5HFmrO9k63T0WeQBl+wLSgw9xGCwDtQ0s+GsxDowUIrficMOlxw1RkhqJw4u +DCQ==
X-Received by 10.13.204.81 with SMTP id o78mr2249020ywd.108.1443137536767; Thu, 24 Sep 2015 16:32:16 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <1443135684451.3744@activenetwerx.com>
References <5cb33b569cf14dfea9424c006c9abc95@exch.activenetwerx.com> <CALwzidm0s48iKMdyzOYwS+nZtBjh_y-Z2yaNi1=Unvsa_Ok1FQ@mail.gmail.com> <CALwzidk5H_hevjuiJjYyJTM9wj5hZbmZa=G9L8ctTZ+geJu+=A@mail.gmail.com> <1443135684451.3744@activenetwerx.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 24 Sep 2015 17:31:37 -0600
Subject Re: Modifying signature of ctor in class
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.154.1443137539.28679.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1443137539 news.xs4all.nl 23839 [2001:888:2000:d::a6]:34908
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3868
X-Received-Body-CRC 2656833750
Xref csiph.com comp.lang.python:97103

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Modifying signature of ctor in class Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-24 17:31 -0600

csiph-web