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


Groups > comp.lang.python > #32490

Re: calling one staticmethod from another

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; '(at': 0.03; 'parameter.': 0.09; 'cc:addr:python-list': 0.10; 'eckhardt': 0.16; 'one)': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'instance,': 0.17; 'java': 0.21; "i'd": 0.22; 'cc:2**0': 0.23; 'class.': 0.23; "haven't": 0.23; 'cc:no real name:2**0': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'c++': 0.27; 'class': 0.29; 'instead,': 0.33; "can't": 0.34; 'except': 0.36; 'but': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'different': 0.63; 'reasons,': 0.65; 'header :Reply-To:1': 0.68; 'obvious': 0.71; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72
Date Tue, 30 Oct 2012 09:47:59 -0400
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1
MIME-Version 1.0
To Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Subject Re: calling one staticmethod from another
References <tit4m9-1ei.ln1@satorlaser.homedns.org>
In-Reply-To <tit4m9-1ei.ln1@satorlaser.homedns.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:dxSCbH0LQu05N+RFvK701yPLTHU0hRN24YJl8j8PzWv 3p8clXyZJm3wIbOL9jxw/yO8+JgK1RJBps/sUGNAzHabV79BlY K8s5I4QbjgIRWohdkjQyjalIHJbjuD2HH+BfnBcMrkP+Aq1IEW +AeR24TkWXBtAu+q+5vmyjWioYjsRnAxR5DbflMTsiI9v0fErh JFxwGJXK/GqEoFlX4lWB58bnC6ZqqRBd+vPcpe2m+PZZw74e38 /vXSA/aL4Ota0LOL84WfAn2U6RqHSzQhlKC7NOVRCoLwayoaMU oXkzUa5fGWm61VHcudAWT981Wsq2nOG3FSGyk1yp0k19cBsVQ= =
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
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.3091.1351604905.27098.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351604905 news.xs4all.nl 6927 [2001:888:2000:d::a6]:42077
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32490

Show key headers only | View raw


On 10/30/2012 08:25 AM, Ulrich Eckhardt wrote:
> Hi!
>
> I can call a staticmethod f() of class C like "C.f()" or with an
> instance like "C().f()". Inside that staticmethod, I have neither the
> class (at least not the original one) nor do I have an instance, so I
> can't call a different staticmethod from the same class. The obvious
> solution is to make this a classmethod instead, with a mostly-unused
> "cls" parameter.
>
> Am I missing something?
>
> Uli

I'd think the obvious solution is to move both the functions outside of
the class.  I haven't figured out the justification for staticmethod,
except for java or C++ converts.

But if you like the staticmethod for other reasons, why is it you can't
just use
      C.g()

?

-- 

DaveA

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


Thread

calling one staticmethod from another Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-30 13:25 +0100
  Re: calling one staticmethod from another Ethan Furman <ethan@stoneleaf.us> - 2012-10-30 06:41 -0700
  Re: calling one staticmethod from another Dave Angel <d@davea.name> - 2012-10-30 09:47 -0400
    Re: calling one staticmethod from another Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-30 16:39 +0100
  Re: calling one staticmethod from another Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-30 09:27 -0600
  Re: calling one staticmethod from another Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-30 21:29 +0000

csiph-web