Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97099
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'modify': 0.04; 'constructor': 0.07; 'dynamically': 0.07; 'attribute.': 0.09; 'example:': 0.10; 'python': 0.10; 'def': 0.13; 'thu,': 0.15; '24,': 0.16; '2:28': 0.16; 'subject:class': 0.16; 'wrote:': 0.16; 'string': 0.17; 'input': 0.18; '2015': 0.20; 'accommodate': 0.22; 'doc': 0.22; 'fine,': 0.22; 'parameter': 0.22; 'sep': 0.22; 'pass': 0.22; 'attach': 0.23; 'import': 0.24; 'header:In-Reply- To:1': 0.24; 'module': 0.25; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; '**kwargs):': 0.29; 'inspect': 0.29; 'strings,': 0.29; 'skip:_ 10': 0.32; 'class': 0.33; 'foo': 0.33; 'this?': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'done': 0.35; 'skip:p 30': 0.35; 'there': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'setting': 0.37; 'signature': 0.37; 'anything': 0.38; 'building': 0.38; 'skip:p 20': 0.38; 'to:addr:python.org': 0.40; 'where': 0.40; 'to:name:python': 0.84; 'dirty': 0.93 |
| 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=hy6Bl9r4TV+wVa0AUNWs6+o9OgZX4BC0pZyRxON3GJc=; b=dbkZp7Brn2eC+LwMZIMchFaRCA+jGyrkoHIvBUUyQIQxAh6tD9BJvZB8yMMy7pOtbY ND1Y05erxK1V2GWM98FAc1Q6VLZqzCGtROVHOfCSwYJX6YKdg7dS5Yh9hn5j/CMdJzGs VX9FXt3nTu9uvBEp79p3BsF24ib8bwx41TcR0QP3nfwtqdIdGSTyRqGBPV7zVl0rily/ ibnmIQaxRgMsM56r+/dowPDVyj9dgj2KyTDi3PBuD/zCVe0C6W/kj+HR6XxXxr9Kk/sP VZvMtkNKz4EOx7iKYfjiQBt9tXqF+2kFm74x/JILnKZlCQJJMGNYCxB9zQiCEOnYV2oa 151A== |
| X-Received | by 10.129.103.67 with SMTP id b64mr1955605ywc.55.1443133209545; Thu, 24 Sep 2015 15:20:09 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <CALwzidm0s48iKMdyzOYwS+nZtBjh_y-Z2yaNi1=Unvsa_Ok1FQ@mail.gmail.com> |
| References | <5cb33b569cf14dfea9424c006c9abc95@exch.activenetwerx.com> <CALwzidm0s48iKMdyzOYwS+nZtBjh_y-Z2yaNi1=Unvsa_Ok1FQ@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 24 Sep 2015 16:19:30 -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.151.1443133217.28679.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1443133217 news.xs4all.nl 23786 [2001:888:2000:d::a6]:47523 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97099 |
Show key headers only | View raw
On Thu, Sep 24, 2015 at 4:10 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Thu, Sep 24, 2015 at 2:28 PM, Joseph L. Casale
> <jcasale@activenetwerx.com> wrote:
>> I have a class factory where I dynamically add a constructor to the class output.
>> The method is a closure and works just fine, however to accommodate the varied
>> input its signature is (*args, **kwargs).
>>
>> While I modify the doc strings, the ctor sig is not optimal. Without building
>> this a string and using eval, is there anything that can be done about this?
>
> In Python 3.3+ you can attach a Signature object to a function by
> setting the function's __signature__ attribute. In Python 3.4+ the
> __signature__ is used in generating the signature for PyDoc and
> help().
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)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Modifying signature of ctor in class Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-24 16:19 -0600
csiph-web