Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'foo': 0.09; 'def': 0.13; '%r"': 0.16; '**kwargs)': 0.16; '**kwargs):': 0.16; '*args,': 0.16; '-tkc': 0.16; 'behavior?': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'thanks,': 0.18; 'suggest': 0.20; 'asked': 0.22; 'print': 0.29; 'second': 0.29; 'class': 0.29; 'config': 0.30; "i've": 0.31; 'header:User-Agent:1': 0.33; 'there': 0.33; 'done': 0.34; 'to:addr :python-list': 0.34; 'things': 0.34; 'something': 0.35; '...': 0.36; 'skip:_ 10': 0.37; 'somewhat': 0.38; 'getting': 0.38; 'to:addr:python.org': 0.40; 'type': 0.61; 'act': 0.65; 'arrangement': 0.93 Date: Thu, 01 Dec 2011 22:02:18 -0600 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Python Subject: Passing along cmd.Cmd completion to contained class 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 - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322798548 news.xs4all.nl 6943 [2001:888:2000:d::a6]:60019 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16522 I have sub-classes of cmd.Cmd in an arrangement somewhat like class Config(cmd.Cmd): def do_foo(self, line): print "Fooing %r" % line def complete_foo(self, text, line, begidx, endidx): ... class MyTUI(cmd.Cmd): def __init__(self, configger=Config, *args, **kwargs): cmd.Cmd.__init__(self, *args, **kwargs) self.config = configger() def complete_config(self, text, line, begidx, endidx): magic_here(self.config, text, line, begidx, endidx) I've been sparring with getting MyTUI.complete_config() to reach into self.config for completions so I can type things like (cmd) config (cmd) config foo and have it suggest from Config as if I had done something like def do_config(self, line) self.config.cmdloop() and then asked for completions. That would mean that the first one would act like Config.completenames() and the second one would act like Config.complete_foo(...) Is there a best way to get this pass-along behavior? Thanks, -tkc