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


Groups > comp.lang.python > #15809

Re: staticmethod makes my brain hurt

References <roy-DD1C5B.21305716112011@news.panix.com> <CAKDXFkMZ=TLYO1sPCU1JMBkNOibchnE361_HGHCX+EbWn_GsBA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2011-11-17 00:37 -0700
Subject Re: staticmethod makes my brain hurt
Newsgroups comp.lang.python
Message-ID <mailman.2795.1321515508.27778.python-list@python.org> (permalink)

Show all headers | View raw


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.

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