[Tutor] scite with python 2.51

2007-09-22 Thread elis aeris
how do I set up scite editor with python so that I can click check syntax and compile from the editor? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Capturing ctrl-c

2007-09-22 Thread Michael Langford
When I do real applications with exception based languages, I almost always wrap the main function with a try/except block to allow me to gracefully shut down. In the case of python, this means 1> Use the main method 2> wrap its execution in a try catch: import mymodule def do_stuff(): pass

[Tutor] Capturing ctrl-c

2007-09-22 Thread James
Hi. :) I'm whipping up a program in Python and am having to deal with a user potentially hitting ctrl-c at any point in the program. I'd like my Python program to wrap up cleanly when it receives this signal. I did some Googling and read that Python throws a KeyboardInterrupt error. What

Re: [Tutor] Counting method calls

2007-09-22 Thread Ricardo Aráoz
Kent Johnson wrote: > One more reference: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252151 > > This appears as recipe 6.6 in the second edition of the printed cookbook. > > Kent Thanks Kent. I guess I got into deep waters. It's a shame though that you can not do this in a simple

Re: [Tutor] Counting method calls

2007-09-22 Thread Kent Johnson
One more reference: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252151 This appears as recipe 6.6 in the second edition of the printed cookbook. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Counting method calls

2007-09-22 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> What version of Python are you using? When I try this program it prints > > Py 0.9.5 > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit > (Intel)] on win32 > > I thought it might be you were trying the class with the list init call >

Re: [Tutor] Quick question

2007-09-22 Thread Tino Dai
On 9/21/07, Jerry Hill <[EMAIL PROTECTED]> wrote: > > On 9/21/07, Tino Dai <[EMAIL PROTECTED]> wrote: > > Is there a more pythonic way of doing this: > > > > if queuePacket.has_key('procSeq') and \ > > queuePacket.has_key('opacSeq') and \ > > queuePacket.has_key('keySeq') and \ > > len(queu

Re: [Tutor] Counting method calls

2007-09-22 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Hi, I'm trying to count method calls. Tried this but... >> class MyList(list): >>> ... def __init__(self): >>> ... self.calls = 0 ... snipped . > I think this does what you want. Notice that it doesn't have anything > special to do

Re: [Tutor] Counting method calls

2007-09-22 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Hi, I'm trying to count method calls. Tried this but... >> class MyList(list): >>> ... def __init__(self): >>> ... self.calls = 0 > > should call list.__init__(self) here. Foolish me. > >>> ... def __getattr__(self, name): >>> ..

Re: [Tutor] Counting method calls

2007-09-22 Thread Kent Johnson
Ricardo Aráoz wrote: > Hi, I'm trying to count method calls. Tried this but... > class MyList(list): >> ... def __init__(self): >> ... self.calls = 0 should call list.__init__(self) here. >> ... def __getattr__(self, name): >> ... self.calls += 1 >> ... return

[Tutor] Counting method calls

2007-09-22 Thread Ricardo Aráoz
Hi, I'm trying to count method calls. Tried this but... class MyList(list): > ... def __init__(self): > ... self.calls = 0 > ... def __getattr__(self, name): > ... self.calls += 1 > ... return list.__getattribute__(self, name) > a = MyList() a > [] >>>