Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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; 'class,': 0.07; 'instance.': 0.09; 'messing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; '(the': 0.15; 'library': 0.15; 'bases,': 0.16; 'creation.': 0.16; 'helpers': 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'jan': 0.18; 'subject:skip:i 10': 0.22; "i'd": 0.22; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'parent': 0.29; 'class': 0.29; 'this.': 0.29; 'classes': 0.30; 'certain': 0.33; 'to:addr:python-list': 0.33; 'form.': 0.33; 'another': 0.33; 'pm,': 0.35; 'subject:?': 0.35; 'there': 0.35; 'add': 0.36; 'received:org': 0.36; 'but': 0.36; 'child': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Deciding inheritance at instantiation? Date: Fri, 03 Aug 2012 17:55:33 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344030962 news.xs4all.nl 6871 [2001:888:2000:d::a6]:53557 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26456 On 8/3/2012 4:48 PM, Tobiah wrote: > I have a bunch of classes from another library (the html helpers > from web2py). There are certain methods that I'd like to add to > every one of them. So I'd like to put those methods in a class, > and pass the parent at the time of instantiation. Web2py has > a FORM class for instance. I'd like to go: > > my_element = html_factory(FORM) > > Then my_element would be an instance of my class, and also > a child of FORM. > > I started messing with decorators, but it became difficult > for me to visualise how to do this. Use type(name, bases, content) for dynamic class creation. -- Terry Jan Reedy