Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15807
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jeanpierreda@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'thread,': 0.04; '(python': 0.05; 'behave': 0.07; 'function,': 0.07; 'python': 0.08; 'builtin': 0.09; 'callable': 0.09; 'callable.': 0.09; 'foo': 0.09; 'foo,': 0.09; 'def': 0.14; '16,': 0.15; 'cc:addr:python-list': 0.15; 'roy': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wed,': 0.17; 'language': 0.17; 'wrote:': 0.18; 'functions,': 0.18; 'received:209.85.210.174': 0.18; 'received :mail-iy0-f174.google.com': 0.18; '(which': 0.19; 'cc:no real name:2**0': 0.21; 'issue.': 0.21; "doesn't": 0.23; 'fine,': 0.23; 'least,': 0.23; 'header:In-Reply-To:1': 0.23; 'cc:2**0': 0.25; 'work,': 0.26; 'function': 0.27; 'url:mailman': 0.27; 'discussed': 0.28; 'pass': 0.28; 'fine.': 0.28; 'fix': 0.29; 'cc:addr:python.org': 0.29; 'message-id:@mail.gmail.com': 0.29; 'second': 0.29; 'print': 0.29; 'class': 0.29; 'broke': 0.30; 'differently': 0.30; 'now)': 0.30; 'url:03': 0.30; "didn't": 0.30; 'nov': 0.31; 'pm,': 0.31; 'objects': 0.32; 'url:listinfo': 0.32; 'does': 0.32; "can't": 0.32; 'quite': 0.32; 'actually': 0.33; '(as': 0.34; 'skip:@ 10': 0.34; 'changing': 0.34; 'however,': 0.34; 'notes': 0.35; 'certain': 0.35; 'unless': 0.35; 'url:python': 0.35; 'before.': 0.36; 'class.': 0.36; 'thread': 0.36; 'url:pipermail': 0.36; 'but': 0.37; 'issue': 0.37; 'steven': 0.38; 'run': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'returned': 0.38; 'subject:: ': 0.39; 'difference': 0.40; 'happens': 0.40; 'received:209': 0.40; 'behind': 0.40; '2011': 0.62; 'eliminate': 0.63; 'making': 0.67; 'url:2011': 0.71; '-0500,': 0.84; '11:43': 0.84; 'imagined': 0.84; 'self.': 0.84; 'url:answers': 0.84; 'url:topic': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=z4eYQD/L+ff42UnQyaJOPyYxTGUuK7vYZhwjnNtMLf4=; b=AhyYN0cw+FtBQ57AQorZvHomHxMqTd4vAt8qfCb8aqvfprTIrye4tBwJV2+pYb0+sq ZFJAQFl/vzZTZatBqkz8x9xWr20eg8cs8Zw5lGFYsikrANC+MTq/Hm7SkAAlx7fWFu5S T931lNHBDHXlDFVnHUovy21X+BKvsxwollUS8= |
| MIME-Version | 1.0 |
| In-Reply-To | <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| References | <roy-DD1C5B.21305716112011@news.panix.com> <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | Thu, 17 Nov 2011 01:20:43 -0500 |
| Subject | Re: staticmethod makes my brain hurt |
| To | "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2791.1321510888.27778.python-list@python.org> (permalink) |
| Lines | 87 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1321510888 news.xs4all.nl 6884 [2001:888:2000:d::a6]:46887 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:15807 |
Show key headers only | View raw
> However, the fix is not as simple as merely making staticmethod objects
> callable. This was discussed at the 2011 language summit:
>
> http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html
>
> See also this thread:
>
> http://mail.python.org/pipermail/python-dev/2011-March/109090.html
The notes didn't actually mention what was discussed, but re the
second thread, the issue was not changing staticmethod to be callable.
Making staticmethod callable is fine, but __get__ still has to return
the original function, not self.
The context of the second thread was that staticmethod was imagined as
one way to eliminate the difference between C and Python functions,
when added to a class. But this doesn't quite work, unless
staticmethod.__get__ returned self (which broke for related reasons).
If it returns the original function (as it does now) then the issue is
unresolved: C functions still behave differently from Python
functions, so you can't quite just hide them behind a staticmethod and
let everything remain the same. It doesn't eliminate the difference in
behavior in certain circumstances, e.g.:
class MyClass:
foo = staticmethod(foo)
class MyOtherClass:
foo = MyClass.foo
MyOtherClass().foo() # what happens if foo is builtin vs pure-Python?
In the context of this thread, though, just making it callable without
modifying __get__ is fine. Or at least, I don't see the issue.
Devin
On Wed, Nov 16, 2011 at 11:43 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote:
>
>> When I run this (python 2.6.1):
>>
>> class C:
>> @staticmethod
>> def foo():
>> pass
>> print "inside", foo, callable(foo)
>>
>> print "outside", C.foo, callable(C.foo)
>>
>> I get:
>>
>> inside <staticmethod object at 0x421df0> False
>> outside <function foo at 0x41e6f0> True
>>
>> I don't understand. Why is foo not callable inside of the class
>> definition?
>
>
> This has come up before.
>
> http://bytes.com/topic/python/answers/34396-static-method-object-not-callable
>
> http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callable
>
>
> However, the fix is not as simple as merely making staticmethod objects
> callable. This was discussed at the 2011 language summit:
>
> http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html
>
> See also this thread:
>
> http://mail.python.org/pipermail/python-dev/2011-March/109090.html
>
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
staticmethod makes my brain hurt Roy Smith <roy@panix.com> - 2011-11-16 21:30 -0500
Re: staticmethod makes my brain hurt alex23 <wuwei23@gmail.com> - 2011-11-16 18:44 -0800
Re: staticmethod makes my brain hurt Roy Smith <roy@panix.com> - 2011-11-16 21:52 -0500
Re: staticmethod makes my brain hurt Ethan Furman <ethan@stoneleaf.us> - 2011-11-16 19:24 -0800
Re: staticmethod makes my brain hurt alex23 <wuwei23@gmail.com> - 2011-11-17 18:31 -0800
Re: staticmethod makes my brain hurt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-17 04:43 +0000
Re: staticmethod makes my brain hurt Roy Smith <roy@panix.com> - 2011-11-17 00:26 -0500
Re: staticmethod makes my brain hurt Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-17 01:20 -0500
Re: staticmethod makes my brain hurt Dotan Cohen <dotancohen@gmail.com> - 2011-11-17 08:44 +0200
Re: staticmethod makes my brain hurt Ian Kelly <ian.g.kelly@gmail.com> - 2011-11-17 00:37 -0700
Re: staticmethod makes my brain hurt Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-11-17 10:17 +0100
Re: staticmethod makes my brain hurt Dotan Cohen <dotancohen@gmail.com> - 2011-11-17 13:13 +0200
Re: staticmethod makes my brain hurt Chris Angelico <rosuav@gmail.com> - 2011-11-17 22:38 +1100
csiph-web