Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80410
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; 'subject:Python': 0.06; 'attribute': 0.07; '%s"': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'subject:method': 0.09; 'subject:set': 0.09; '~ethan~': 0.09; 'python': 0.11; 'def': 0.12; 'bug': 0.12; '%s,': 0.16; '(x,': 0.16; '@property': 0.16; 'callable.': 0.16; 'descriptor': 0.16; 'evaluating': 0.16; 'invoking': 0.16; 'subject:Dev': 0.16; 'typeerror:': 0.16; 'y):': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'seems': 0.21; 'import': 0.22; '(in': 0.22; 'header:User- Agent:1': 0.23; 'of.': 0.24; 'looks': 0.24; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'skip:p 30': 0.29; "doesn't": 0.30; 'returned': 0.30; "i'm": 0.30; 'inspect': 0.31; 'work:': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'but': 0.35; 'there': 0.35; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'called': 0.40; 'how': 0.40; 'received:173': 0.61; "you're": 0.61; 'more': 0.64; 'behavior': 0.77; '"look': 0.84; 'examining': 0.84; 'technique': 0.93 |
| Date | Sat, 08 Nov 2014 19:27:41 -0800 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: [Python-Dev] Dinamically set __call__ method |
| References | <CAF0TK51TKs+tw=u_rzrWVeSsDK7cOBt1Gcvq_izLfMObuDYNig@mail.gmail.com> <545919B6.7040007@stoneleaf.us> <CAF0TK52vw_SmqexN8RXyGs8GSKecPobK54ZqYPyKgRSSJy9zWw@mail.gmail.com> <mailman.15467.1415128339.18130.python-list@python.org> <c25aa612-bff2-4982-8fb9-5b17a866bead@googlegroups.com> <87a943qyvn.fsf@handshake.de> <545CC204.2010301@stoneleaf.us> <8761eq424e.fsf@handshake.de> <mailman.15584.1415476169.18130.python-list@python.org> <cc7jtiFubltU1@mid.individual.net> |
| In-Reply-To | <cc7jtiFubltU1@mid.individual.net> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.15590.1415503665.18130.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1415503665 news.xs4all.nl 2830 [2001:888:2000:d::a6]:43108 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:80410 |
Show key headers only | View raw
On 11/08/2014 02:31 PM, Gregory Ewing wrote:
>
> Seems to depend on how you get hold of the object you're
> inspecting the signature of. I did an experiment:
>
> class C(object):
>
> @property
> def __call__(self):
> return self.call
>
> def f(x, y):
> print("Called f with %s, %s" % (x, y))
>
> c = C()
> c.call = f
> c(17, 42)
>
> prints:
> Called f with 17, 42
>
> This works too:
>
> import inspect
> print(inspect.getargspec(c.__call__))
>
> prints:
> ArgSpec(args=['x', 'y'], varargs=None, keywords=None, defaults=None)
>
> But
>
> print(inspect.getargspec(c))
>
> doesn't work:
>
> TypeError: <__main__.C object at 0x479250> is not a Python function
>
> (BTW, I'm actually surprised that this technique makes c callable.
> There must be more going on that just "look up __call__ in the class
> object", because evaluating C.__call__ just returns the descriptor
> and doesn't invoking the descriptor mechanism.)
Looks like you found a bug in inspect.getargspec.
And the thing going on is the normal python behavior (in __getattribute__, I believe) of examining the returned
attribute to see if it is a descriptor, and if so invoking it.
--
~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-04 11:12 -0800
Re: [Python-Dev] Dinamically set __call__ method John Ladasky <john_ladasky@sbcglobal.net> - 2014-11-06 12:21 -0800
Re: [Python-Dev] Dinamically set __call__ method dieter <dieter@handshake.de> - 2014-11-07 07:59 +0100
Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-07 04:58 -0800
Re: [Python-Dev] Dinamically set __call__ method dieter <dieter@handshake.de> - 2014-11-08 07:50 +0100
Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-08 11:49 -0800
Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-09 11:31 +1300
Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-08 19:27 -0800
Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-10 00:38 +1300
Re: [Python-Dev] Dinamically set __call__ method Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-10 00:14 +1100
Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-09 12:16 -0800
Re: [Python-Dev] Dinamically set __call__ method Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-11 00:43 -0700
Re: [Python-Dev] Dinamically set __call__ method Fabio Zadrozny <fabiofz@gmail.com> - 2014-11-12 13:33 -0200
Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-13 17:20 +1300
Re: [Python-Dev] Dinamically set __call__ method Fabio Zadrozny <fabiofz@gmail.com> - 2014-11-13 11:38 -0200
Re: [Python-Dev] Dinamically set __call__ method Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-12 11:58 -0700
csiph-web