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


Groups > comp.lang.python > #50516

Re: Callable or not callable, that is the question!

From Peter Otten <__peter__@web.de>
Subject Re: Callable or not callable, that is the question!
Date 2013-07-12 12:36 +0200
Organization None
References <n6n2ba-ubg.ln1@satorlaser.homedns.org> <mailman.4586.1373551911.3114.python-list@python.org> <11l4ba-u4l.ln1@satorlaser.homedns.org> <XnsA1FB578CDBB3Cduncanbooth@127.0.0.1> <51dfd11a$0$9505$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.4628.1373625429.3114.python-list@python.org> (permalink)

Show all headers | View raw


Steven D'Aprano wrote:

> On Fri, 12 Jul 2013 07:36:30 +0000, Duncan Booth wrote:
> 
>> To be a convincing use-case you would have to show a situation where
>> something had to be both a static method and a utility method rather
>> than just one or the other and also where you couldn't just have both.
> 
> I have a class where I have a function that needs to be called both while
> the class is being constructed, and afterwards:
> 
> class Example:
>     @staticmethod
>     def do_stuff(arg):
>         ...
> 
>     do_stuff(23)  # This doesn't work.
> 
> Example.do_stuff(42)

That is a bit too abstract for my taste to count as a use-case. 

Also, as given the example will work in Python 3 when you remove the 
@staticmethod ;)

That said I can see that the error comes as a surprise and I would be fine 
with callable staticmethod objects.

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


Thread

Callable or not callable, that is the question! Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-11 15:05 +0200
  Re: Callable or not callable, that is the question! Peter Otten <__peter__@web.de> - 2013-07-11 16:11 +0200
    Re: Callable or not callable, that is the question! Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-12 08:41 +0200
      Re: Callable or not callable, that is the question! Duncan Booth <duncan.booth@invalid.invalid> - 2013-07-12 07:36 +0000
        Re: Callable or not callable, that is the question! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-12 09:49 +0000
          Re: Callable or not callable, that is the question! Peter Otten <__peter__@web.de> - 2013-07-12 12:36 +0200
  Re: Callable or not callable, that is the question! Jason Swails <jason.swails@gmail.com> - 2013-07-11 10:28 -0400
  Re: Callable or not callable, that is the question! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-12 02:12 +0000
    Re: Callable or not callable, that is the question! Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-12 01:11 -0600

csiph-web