Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97097
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <rosuav@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; 'args': 0.04; 'cc:addr :python-list': 0.09; 'definition,': 0.09; 'ide': 0.09; 'rebuild': 0.09; 'tab': 0.09; 'python': 0.10; 'itself.': 0.11; 'argument': 0.15; '7:45': 0.16; 'at,': 0.16; 'chris,': 0.16; 'docstring': 0.16; 'eval': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'stuff,': 0.16; 'subject:class': 0.16; 'wrote:': 0.16; 'string': 0.17; 'attribute': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'work,': 0.21; 'fairly': 0.22; 'sep': 0.22; 'am,': 0.23; '(or': 0.23; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'equivalent': 0.27; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'function': 0.28; 'idea': 0.28; 'looks': 0.29; 'does,': 0.29; 'helpful.': 0.29; 'too.': 0.30; 'possibly': 0.32; 'point': 0.33; 'class': 0.33; 'problem': 0.33; '(for': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'something': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'instead': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'mean': 0.38; 'whatever': 0.39; 'easily': 0.39; 'where': 0.40; 'still': 0.40; 'your': 0.60; "you'll": 0.61; 'entire': 0.61; 'effective': 0.63; 'completing': 0.72; 'completion': 0.79; 'chrisa': 0.84; 'construct': 0.84; "it'd": 0.84; 'to:none': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=L8fSgomosZTILrAorNOay6++GMEs5BkoFdTC5a0NlwQ=; b=WFwciD6mSYkE6UCPZsSrdbkdCTHkeVu5rIy06MOxJZtKkK9TAMJbT2LC5NKmpbyscv wy6Ssynw0UOJnkQBeDS94EbrJAUVrrqmva/TSy5rGSDyZnshWE/yaQpqPscMqReQQ1DH 3AG/LVIaxsajE06wgg/oCZbgIxgg3QUaO4Zgtdpvy5SCYZyALvBKmCYw4NuB1VvXF7IG klNR+U6/KcbwGQsVmc+Vl7rz1ldD5kDHu3XV/yzBQNXQ8zsAqDJJWJDosbkaiWQYOszO FCduozW2TbR4NNssi9tanylak68B/X/Cexdp1TvthHJL7zg+29Nr5OPtc9C22B9jKKpQ xwMQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.107.36.72 with SMTP id k69mr2926376iok.157.1443132446562; Thu, 24 Sep 2015 15:07:26 -0700 (PDT) |
| In-Reply-To | <1443131144678.39404@activenetwerx.com> |
| References | <5cb33b569cf14dfea9424c006c9abc95@exch.activenetwerx.com> <CAPTjJmqCmXOx=KfkewnR7GR__qU0NPS7R=aqZ0BK_N4J9zXiBg@mail.gmail.com> <1443131144678.39404@activenetwerx.com> |
| Date | Fri, 25 Sep 2015 08:07:26 +1000 |
| Subject | Re: Modifying signature of ctor in class |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <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.149.1443132450.28679.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1443132450 news.xs4all.nl 23768 [2001:888:2000:d::a6]:41488 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97097 |
Show key headers only | View raw
On Fri, Sep 25, 2015 at 7:45 AM, Joseph L. Casale <jcasale@activenetwerx.com> wrote: >> I don't think you can easily change the function's own definition, >> other than by using eval (or equivalent shenanigans, like crafting >> your own bytecode); but as of Python 3.something, the help() function >> looks for a __wrapped__ attribute and will take function args from >> that instead of the function itself. That way, when you use >> functools.wraps(), it copies in the docstring and stuff, and as far as >> help() is concerned, copies in the argument list too. >> >> No idea whether you'll be able to do that too, but it's a fairly >> effective way to get around the problem if you can. > > Hi Chris, > That is helpful. It still leaves me with generating a string function > and eval'ing or compiling it to swipe the sig. At the point I could > rebuild the entire function and simply apply it. > > Where all but a valid sig helps is for introspection such as tab completing > with ipython or using an IDE etc. I've no idea what your tab completion tools are going to be looking at, so you'd have to dig into that and find out. This trick may or may not work, but if it does, it'd mean you could possibly come up with something that pretends to be a function (for introspection purposes), without actually being one. That would let you construct a class that ducktypes as a function and can return whatever it likes from inspect.signature(). ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Modifying signature of ctor in class Chris Angelico <rosuav@gmail.com> - 2015-09-25 08:07 +1000
csiph-web