Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!weretis.net!feeder5.news.weretis.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.04; 'instance': 0.05; 'python': 0.07; 'attribute.': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:74.54.199': 0.09; 'received:74.54.199.50': 0.09; 'received:gator410.hostgator.com': 0.09; 'subclasses': 0.09; '~ethan~': 0.09; 'def': 0.13; 'wrote:': 0.14; 'chad': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'subject:Classes': 0.16; 'class,': 0.16; 'header:In-Reply-To:1': 0.22; 'subject:question': 0.22; 'pass': 0.27; 'class': 0.29; 'to:addr:python-list': 0.32; 'created': 0.33; 'test': 0.33; 'there': 0.35; 'print': 0.35; 'header:User-Agent:1': 0.35; 'to:addr:python.org': 0.39; 'how': 0.39; 'header:Received:5': 0.40; 'received:74.54': 0.60; 'skip:h 20': 0.60; 'received:hostgator.com': 0.64; 'subject:about': 0.66; 'received:websitewelcome.com': 0.71; 'received:gateway09.websitewelcome.com': 0.84 Date: Thu, 21 Apr 2011 11:34:49 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: python-list@python.org Subject: Re: A question about Python Classes References: <2219ee53-e8aa-4ac4-839f-014c3d1b1914@a19g2000prj.googlegroups.com> In-Reply-To: <2219ee53-e8aa-4ac4-839f-014c3d1b1914@a19g2000prj.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:3650 X-Source-Cap: su.faelenots+nahte X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303410257 news.xs4all.nl 81475 [::ffff:82.94.164.166]:47374 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3816 chad wrote: > 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? You don't need to create an instance of BaseHandler. You have the class, Python knows you have the class -- Python will look there if the subclasses lack an attribute. ~Ethan~