Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32497
| References | <tit4m9-1ei.ln1@satorlaser.homedns.org> <508FD8F1.7080102@stoneleaf.us> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-10-30 09:27 -0600 |
| Subject | Re: calling one staticmethod from another |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3095.1351610873.27098.python-list@python.org> (permalink) |
On Tue, Oct 30, 2012 at 7:41 AM, Ethan Furman <ethan@stoneleaf.us> wrote:
> class Spam():
> @staticmethod
> def green():
> print('on a train!')
> @staticmethod
> def question():
> print('would you, could you', end='')
> Spam.green()
>
> It can be a pain if you change the class name, but it is certainly one way
> to do it.
It fails if the staticmethod being called has been overridden in a
subclass, though. I think the only correct way to do it with
inheritance is by replacing it with a classmethod, as the OP
suggested.
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