From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11326 invoked by alias); 10 Jan 2010 08:14:26 -0000 Received: (qmail 11315 invoked by uid 22791); 10 Jan 2010 08:14:25 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from lo.gmane.org (HELO lo.gmane.org) (80.91.229.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 10 Jan 2010 08:14:19 +0000 Received: from list by lo.gmane.org with local (Exim 4.50) id 1NTswB-0006ji-Ed for gdb-patches@sources.redhat.com; Sun, 10 Jan 2010 09:14:15 +0100 Received: from cpe-67-247-228-249.buffalo.res.rr.com ([67.247.228.249]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Jan 2010 09:14:15 +0100 Received: from daniel by cpe-67-247-228-249.buffalo.res.rr.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Jan 2010 09:14:15 +0100 To: gdb-patches@sources.redhat.com From: Daniel Colascione Subject: Re: Less verbose Python commands Date: Sun, 10 Jan 2010 08:14:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 In-Reply-To: X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00222.txt.bz2 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 1/10/10 3:00 AM, Daniel Colascione wrote: > [snip] Err, this version propagates docstrings to command help too: def command(*init_args): def decorator(func): def init_func(self): gdb.Command.__init__(self, *init_args) def invoke_func(self, argument, from_tty): func(argument, from_tty) type('Command_' + init_args[0].replace(' ', '_'), (gdb.Command,), { '__init__': init_func, '__doc__': func.__doc__, 'invoke': invoke_func })() return func return decorator @command('tracked', COMMAND_DATA, COMPLETE_NONE, True) def func(argument, from_tty): "Commands having to do with tracked things" @command('tracked types', COMMAND_DATA) def func(argument, from_tty): "List the types of objects which are tracked" print parse_and_eval('2+2') # etc. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) iEYEARECAAYFAktJjEAACgkQ17c2LVA10VutRwCgucOLY5Vn8aNS2+XZZUpSZUaA AfUAn0m+MbHAcrC1LuL3jrdPH17QO1st =Y4db -----END PGP SIGNATURE-----