Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #250
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "Pascal J. Bourguignon" <pjb@informatimago.com> |
| Newsgroups | comp.lang.python, comp.programming |
| Subject | Re: A question about Python Classes |
| Date | Thu, 21 Apr 2011 19:12:11 +0200 |
| Organization | Informatimago |
| Lines | 30 |
| Message-ID | <87k4enil5g.fsf@kuiper.lan.informatimago.com> (permalink) |
| References | <2219ee53-e8aa-4ac4-839f-014c3d1b1914@a19g2000prj.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | individual.net osYn5Q5w5jxX6bKTr8YgqQwlvSUoNio8Xj3hAGO1VqmGa+h3wj |
| Cancel-Lock | sha1:NWI0NjE5ZDk3Y2QzNTQ4NTdkZWE3Y2JiMDNhNzFlYjllODhmNDdiZg== sha1:Ow85+stvLcMlgzkm2OspS4dYm6Y= |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== |
| X-Accept-Language | fr, es, en |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:3812 comp.programming:250 |
Cross-posted to 2 groups.
Show key headers only | View raw
chad <cdalten@gmail.com> writes:
> Let's say I have the following....
>
> class BaseHandler:
> def foo(self):
> print "Hello"
>
> class HomeHandler(BaseHandler):
> pass
>
>
> Then I do the following...
>
> test = HomeHandler()
> test.foo()
>
> How can HomeHandler call foo() when I never created an instance of
> BaseHandler?
But you created one!
test is an instance of HomeHandler, which is a subclass of BaseHandler,
so test is also an instance of BaseHandler.
A subclass represents a subset of the instances of its super class.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Back to comp.programming | Previous | Next — Previous in thread | Find similar
A question about Python Classes chad <cdalten@gmail.com> - 2011-04-21 08:43 -0700 Re: A question about Python Classes "Pascal J. Bourguignon" <pjb@informatimago.com> - 2011-04-21 19:12 +0200
csiph-web