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


Groups > comp.lang.python > #15816

Re: staticmethod makes my brain hurt

References <roy-DD1C5B.21305716112011@news.panix.com> <CAKDXFkMZ=TLYO1sPCU1JMBkNOibchnE361_HGHCX+EbWn_GsBA@mail.gmail.com> <CALwzidn0GsfapWEK20Csb5Fwh1D6wA=o05zdxoA8k-63HoO1Mw@mail.gmail.com>
Date 2011-11-17 13:13 +0200
Subject Re: staticmethod makes my brain hurt
From Dotan Cohen <dotancohen@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2803.1321528426.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Nov 17, 2011 at 09:37, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen <dotancohen@gmail.com> wrote:
>> Try this (untested):
>>
>> class C:
>>   @staticmethod
>>   def foo():
>>       pass
>>
>>   print "inside", C.foo, callable(C.foo)
>
> If you had tested this, you would have found that you get a NameError,
> since C is not yet bound inside the class block where you define it.
>

I hadn't tested, I'm at work far from Idle. Just shooting from the hip.

For that matter, though, this does work in Java (I'm pretty sure but
again, untested right now).

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

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


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