From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27283 invoked by alias); 22 Mar 2011 15:00:04 -0000 Received: (qmail 27182 invoked by uid 22791); 22 Mar 2011 15:00:01 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_BJ X-Spam-Check-By: sourceware.org Received: from mail-iw0-f169.google.com (HELO mail-iw0-f169.google.com) (209.85.214.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Mar 2011 14:59:26 +0000 Received: by iwl42 with SMTP id 42so9775524iwl.0 for ; Tue, 22 Mar 2011 07:59:24 -0700 (PDT) Received: by 10.42.243.9 with SMTP id lk9mr8528icb.297.1300805960049; Tue, 22 Mar 2011 07:59:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.43.59.10 with HTTP; Tue, 22 Mar 2011 07:59:00 -0700 (PDT) In-Reply-To: References: From: Kevin Pouget Date: Tue, 22 Mar 2011 15:00:00 -0000 Message-ID: Subject: Re: Python objfile-gdb.py file -- how to handle reloading properly ? To: mark florisson , gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00114.txt.bz2 Thanks for your answer Mark (I know I'm not very good at Python, I use it only since a few days :) >> class my_list: >> =A0 =A0list =3D [] >> >> =A0 =A0def addToList(elt): >> =A0 =A0 =A0 =A0my_list.__class__.list.append(elt) > > That should read 'self.list.append(elt) (and you forgot the first > parameter 'self' to 'addToList'). actually, it's rather @staticmethod def addToList(elt): that I wanted to do, that is, access a *static* attribute > Yes, it is quite terrible (also, don't use a bare 'except' clause). If > you want your code to be autoloaded with your object file, have your > script import your actual code instead (that can be installed using > distutils). Modules are cached, so it will only be imported once. what would you think about caching the already-loaded module list, and allowing them to register a callback? That's for instance what is done in `linux-thread-db.c` to detect the loading of the libpthread.so, and that's pretty much what I would like to do. (I mean, if you guys feel like it's an interesting feature but no one fancies doing it, I could give it a try) > Although not related directly to your problem, I suggest reading > docs.python.org/tut. will do, thanks Kevin