Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32490
| Date | 2012-10-30 09:47 -0400 |
|---|---|
| From | Dave Angel <d@davea.name> |
| Subject | Re: calling one staticmethod from another |
| References | <tit4m9-1ei.ln1@satorlaser.homedns.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3091.1351604905.27098.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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