Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; "(it's": 0.09; 'decorator': 0.09; 'subclass': 0.09; 'url:activestate': 0.09; '[1].': 0.16; 'docstring': 0.16; 'docstrings': 0.16; 'inheriting': 0.16; 'metaclass': 0.16; 'metaclasses': 0.16; 'matching': 0.16; 'thanks!': 0.16; 'url:code': 0.17; 'to:name:python-list': 0.19; 'objects': 0.23; 'function': 0.25; 'message-id:@mail.gmail.com': 0.28; 'subject:how': 0.29; 'subject:?': 0.29; 'bound': 0.29; 'class.': 0.29; 'class': 0.29; 'decorators': 0.30; 'received:209.85.215': 0.30; 'to:addr:python-list': 0.33; 'thinking': 0.34; 'however,': 0.34; '[1]': 0.34; 'there': 0.35; 'using': 0.35; 'idea': 0.36; 'too.': 0.37; 'received:google.com': 0.37; 'something': 0.37; 'change': 0.37; 'received:209.85': 0.37; 'url:python': 0.38; 'hoping': 0.38; 'url:org': 0.38; 'realize': 0.38; 'sometimes': 0.39; 'received:209': 0.39; 'got': 0.39; 'to:addr:python.org': 0.39; 'missing': 0.40; 'really': 0.40; 'p.s.': 0.67; '(after': 0.67; 'inheritance,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=IYhXGoEH9UUR+gDjKUhfTpGLYC8mfOwqNzfRIcq1tM0=; b=kXNnL+54neA8P6VVjXaSAkGOrx67NeU2jmtAn2EIXbsUbE7H5vOFpXLBCQzvhOEMUu ixChvsQbI1XyyolfxXIZxzB5ksM3TeqjoW2uf3Aq2vgkXdp2FokGCAsDLJUm7tKZLeHG JuFNZ98fYmUMut/6H8jH5Mbdp3Swphw6YYXjs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=cPZRAr3W+/0k29BTVDvfpJuMA35HDmbDaq7fbIRWEpsnWGaL6iXBVhRHXiBsi6ItEd AQhkaNx8G0dcoOlruPhNacgOg1Ujs3RAEYN16ZQ67+DORqvXud1OwbVnRAus62hFrI9B H9h+Z3MlLX+Z1BDUHzcnM2FNO/FxL4VkelBVw= MIME-Version: 1.0 Date: Thu, 9 Jun 2011 00:22:54 -0600 Subject: how to inherit docstrings? From: Eric Snow To: python-list Content-Type: text/plain; charset=ISO-8859-1 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: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1307600576 news.xs4all.nl 49176 [::ffff:82.94.164.166]:36760 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7273 Sometimes when using class inheritance, I want the overriding methods of the subclass to get the docstring of the matching method in the base class. You can do this with decorators (after the class definition), with class decorators, and with metaclasses [1]. However, I was hoping for a way to do it with just function decorators on the methods (no metaclass or class decorator). I am not sure if this is doable. I realize now that this is exactly the reason I got to thinking last week about objects being notified when they are bound [2]. So, is there a way to do this with just decorators, or am I "stuck" with the metaclass/class decorator route? (It's not all that bad :) Thanks! -eric p.s. Am I missing something or can you really not change the docstring of a class? I was thinking about the idea of inheriting class docstrings too. [1] http://code.activestate.com/recipes/577743-using-decorators-to-inherit-function-docstrings/ [2] http://mail.python.org/pipermail/python-ideas/2011-June/010446.html