Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'example:': 0.03; 'subject:not': 0.03; 'static': 0.04; 'booth': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:question': 0.10; 'python': 0.11; 'def': 0.12; 'callable': 0.16; 'objects.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'fine': 0.24; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'skip:@ 10': 0.30; 'work.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:that': 0.31; 'class': 0.32; 'fri,': 0.33; 'subject:the': 0.34; 'something': 0.35; 'method': 0.36; 'too': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'remove': 0.60; 'show': 0.63; 'situation': 0.65; 'jul': 0.74; 'surprise': 0.74; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Callable or not callable, that is the question! Date: Fri, 12 Jul 2013 12:36:55 +0200 Organization: None References: <11l4ba-u4l.ln1@satorlaser.homedns.org> <51dfd11a$0$9505$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084805d.dip0.t-ipconnect.de User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373625429 news.xs4all.nl 16003 [2001:888:2000:d::a6]:55770 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50516 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.