Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83789
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Calling a derived class's constructor from a parent method |
| Date | 2015-01-15 04:44 +0000 |
| References | <cb109c66-090a-4779-b00e-43d964ae7252@googlegroups.com> <54b70c8c$0$12999$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17738.1421297070.18130.python-list@python.org> (permalink) |
On 15/01/2015 00:40, Steven D'Aprano wrote: > jason wrote: > >> class B(A): >> def __init__(self, s): >> A.__init__(self, s) > > Unrelated: > > It is better to call super than manually call the superclass. Calling A > directly means your class is no longer compatible with multiple > inheritance. > > def __init__(self, s): > super(B, self).__init__(s) > For the OP an excellent article on super here https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Calling a derived class's constructor from a parent method jason <jasonsewall@gmail.com> - 2015-01-14 08:45 -0800
Re: Calling a derived class's constructor from a parent method Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-14 10:00 -0700
Re: Calling a derived class's constructor from a parent method Chris Angelico <rosuav@gmail.com> - 2015-01-15 03:56 +1100
Re: Calling a derived class's constructor from a parent method Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-14 17:05 +0000
Re: Calling a derived class's constructor from a parent method jason <jasonsewall@gmail.com> - 2015-01-14 10:10 -0800
Re: Calling a derived class's constructor from a parent method Dave Angel <davea@davea.name> - 2015-01-14 13:41 -0500
Re: Calling a derived class's constructor from a parent method alister <alister.nospam.ware@ntlworld.com> - 2015-01-14 18:18 +0000
Re: Calling a derived class's constructor from a parent method Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-15 11:40 +1100
Re: Calling a derived class's constructor from a parent method Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-15 04:44 +0000
csiph-web