[Tutor] Fwd: How to stop a script.

2007-12-28 Thread Ian Egland
Thanks, I will keep that in mind the next time I "experiment". :-P -Ian -- Forwarded message -- From: Tiger12506 <[EMAIL PROTECTED]> Date: Dec 28, 2007 5:42 PM Subject: Re: [Tutor] How to stop a script. To: tutor@python.org Ctrl+c will issue a KeyboardInterrupt which breaks out

Re: [Tutor] How to stop a script.

2007-12-28 Thread Tiger12506
Ctrl+c will issue a KeyboardInterrupt which breaks out of programs such as the one you described. (The only situation it doesn't is when the program catches that exception. You won't see that 'til you get your sea legs ;-) ___ Tutor maillist - Tutor

Re: [Tutor] Tutor] Careful Dictionary Building

2007-12-28 Thread Kent Johnson
doug shawhan wrote: > To help performance a bit, don't call dict.keys() on every iteration, > since you're invoking a function. > > dict = {} > allKeys =dict.Keys Should be dict.keys() > for record in list > if record[0] in allKeys: > dict[ record[0] .append(

Re: [Tutor] How to stop a script.

2007-12-28 Thread Ian Egland
Yea I think that I will wait till I get sea legs for the first time, hehe. On Dec 28, 2007 1:16 PM, Marc Tompkins <[EMAIL PROTECTED]> wrote: > As far as I know, not unless you either 1) use threading and put the > killable process in a separate thread or 2) stop and check for input once in > a wh

Re: [Tutor] Tutor] Careful Dictionary Building

2007-12-28 Thread doug shawhan
Lots of very good answers to a pretty stupid question! *blush* I guess there is more than one way to do it! Uh ... guys? Did I say something wrong...? On Dec 28, 2007 12:23 PM, Tony *** <[EMAIL PROTECTED]> wrote: > Hello Doug, > > You can also use exceptions instead of the if /else. It has mo

Re: [Tutor] Careful Dictionary Building

2007-12-28 Thread Michael Langford
This functionality already exists in the ever so useful defaultdict object. You pass a factory method to the constructor of defaultdict for an object, and it returns a new object when there is no key: from collections import defaultdict mydict = defaultdict(list) for record in mylist: mydi

Re: [Tutor] Careful Dictionary Building

2007-12-28 Thread Chris Fuller
first thing.. you are duplicating a lot of effort inside your loops. getting rid of that will speed things up: dict = {} for record in list: rid = record[0]     if rid in dict:     dict[ rid ].append( record )     else:     dict[ rid ] = [record] The other thing I see isn't a speed p

Re: [Tutor] Careful Dictionary Building

2007-12-28 Thread Eric Brunson
doug shawhan wrote: > *sigh* Ignore folks. I had forgotten about .has_key(). Actually, you don't even need that, simply write: if record[0] in dict: # Do your thing. But don't use "dict" as a variable name, it's a builtin function name. > > > > On Dec 28, 2007 11:22 AM, doug shawhan <[EMAIL

[Tutor] How to stop a script.

2007-12-28 Thread Ian Egland
Hi everyone... I litterally just started python and did the following 'hello world' related tutorial. http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro Being the kind of person who like to experiment, I tried changing the following scrip

Re: [Tutor] send file/mail to imap

2007-12-28 Thread Eric Brunson
Tim's pretty spot on in his ruminations below, I just wanted to add a few comments. Read inline. Tim Golden wrote: > Tim Michelsen wrote: > >> I have a mbox file locally on my notebook. >> >> I would like to send this file to my IMAP account using python. >> > > Ummm. There seem to be t

Re: [Tutor] Careful Dictionary Building

2007-12-28 Thread doug shawhan
*sigh* Ignore folks. I had forgotten about .has_key(). On Dec 28, 2007 11:22 AM, doug shawhan <[EMAIL PROTECTED]> wrote: > I'm building a dictionary from a list with ~ 1M records. > > Each record in the list is itself a list. > Each record in the list has a line number, (index 0) which I wish t

[Tutor] Careful Dictionary Building

2007-12-28 Thread doug shawhan
I'm building a dictionary from a list with ~ 1M records. Each record in the list is itself a list. Each record in the list has a line number, (index 0) which I wish to use as a dictionary key. The problem: It is possible for two different records in the list to share this line number. If they do,

Re: [Tutor] send file/mail to imap

2007-12-28 Thread Chris Fuller
On Friday 28 December 2007 09:31, Tim Michelsen wrote: > Hello, > I have a mbox file locally on my notebook. > > I would like to send this file to my IMAP account using python. > > Does anyone know a module or tutorial which does this? > > I tried > * IMAPClient 0.3 - http://pypi.python.org/pypi/IM

Re: [Tutor] send file/mail to imap

2007-12-28 Thread Tim Golden
Tim Michelsen wrote: > I have a mbox file locally on my notebook. > > I would like to send this file to my IMAP account using python. Ummm. There seem to be two possible sources of confusion here. Number one is that you don't normally "send" things via IMAP, you use the IMAP protocol to *read* m

[Tutor] send file/mail to imap

2007-12-28 Thread Tim Michelsen
Hello, I have a mbox file locally on my notebook. I would like to send this file to my IMAP account using python. Does anyone know a module or tutorial which does this? I tried * IMAPClient 0.3 - http://pypi.python.org/pypi/IMAPClient/0.3 but it doesn't contain a send function. Thanks in advanc

Re: [Tutor] Closing GUI program

2007-12-28 Thread Michael H. Goldwasser
Hi Jim, The problem with your code is that Tk's mainloop continues to run even though you have closed the window. The cleaner way to close such a GUI program is to explicitly stop the main loop and the Python interpreter at the appropriate time. In this particular case, you may provid

Re: [Tutor] Internet Bandwidth Management

2007-12-28 Thread Tim Golden
Sewqyne Olpo wrote: > Hello. I want to restrict internet conncection on windows xp > machine,sometimes to cut off the connection or to reduce the bandwidth > .. But I dont know exactly where to start and what to learn. Could you > give some hints about this? > Thanks in advance. Couple of things:

Re: [Tutor] python CLI parser

2007-12-28 Thread Chris Fuller
TUGZip (www.tugzip.com) is another free (as in speech) alternative. It has a distinct interface from 7-zip that some may prefer. Cheers ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Internet Bandwidth Management

2007-12-28 Thread Sewqyne Olpo
Hello. I want to restrict internet conncection on windows xp machine,sometimes to cut off the connection or to reduce the bandwidth .. But I dont know exactly where to start and what to learn. Could you give some hints about this? Thanks in advance. ___

Re: [Tutor] Microsoft Access

2007-12-28 Thread Alan Gauld
"Jim Morcombe" <[EMAIL PROTECTED]> wrote > This tutorial seems very specific to PythonWin IDE. > I haven't tried it, but it seems to imply that it uses stuff > from PythonWin IDE that may not be available in IDLE. The IDE is just an IDE - editor and debugger etc. But the winall package is h

Re: [Tutor] Closing GUI program

2007-12-28 Thread Alan Gauld
"Jim Morcombe" <[EMAIL PROTECTED]> wrote > I run it, (By pressing F5 from IDLE), it displays the "Hello world" > message. Don't run GUI programs from within IDLE is the best advice I can give. It's a lot better than it was and at least they run now but IDLE still catches too many keystrokes and

Re: [Tutor] python CLI parser

2007-12-28 Thread Marc Tompkins
On Dec 28, 2007 2:11 AM, Simone <[EMAIL PROTECTED]> wrote: > bob gailer ha scritto: > > >> could you have a short review of my CLI package. > > .bz2??? What does that extension mean? (For us Windows folk). Or could > > you attach a simple zip file? > > .bz2 is an archive compressed with the bzip2

Re: [Tutor] python CLI parser

2007-12-28 Thread Simone
bob gailer ha scritto: >> could you have a short review of my CLI package. > .bz2??? What does that extension mean? (For us Windows folk). Or could > you attach a simple zip file? .bz2 is an archive compressed with the bzip2 compression program. If you're on Windows, consider to use 7zip for m

Re: [Tutor] Dynamically named objects

2007-12-28 Thread Chris Fuller
You might find a dictionary useful. Each element in a dictionary is associated with a "key", which can be a string. objectlist = {} o = eval("class1" + "()") objectlist["object1"] = o o.method("hello world") Also, try to avoid using eval(), it usually makes troubleshooting and maintenance hard

Re: [Tutor] Dynamically named objects

2007-12-28 Thread Marc Tompkins
Here's the same thing with a list instead of a dictionary: #=== class thingy(): example = "Just testing - " def __init__(self, num): self.example = self.example + str(num) thang = [] for x in range(1,4): thang.append(thingy(x)) for item,

Re: [Tutor] Dynamically named objects

2007-12-28 Thread Marc Tompkins
Sorry, meant to respond to the list, not just the OP... -- Forwarded message -- From: Marc Tompkins <[EMAIL PROTECTED]> Date: Dec 28, 2007 12:13 AM Subject: Re: [Tutor] Dynamically named objects To: Michael Bernhard Arp Sørensen <[EMAIL PROTECTED]> I don't think there's any need