Re: [Tutor] File transfer

2010-10-31 Thread Steven D'Aprano
Chris King quoted Corey Richardson: On 10/31/2010 12:03 PM, Corey Richardson wrote: [...] To read from a file, you open it, and then read() it into a string like this: for line in file: string += string + file.readline() Aii! Worst way to read from a file *EVAR*!!! Seriously. Don'

[Tutor] gauge of the fram

2010-10-31 Thread Ahmed AL-Masri
Hi all, sorry for long message but just read the red highlighted lines I am facing a problem with gauge update. I want to return a value from another script file but the problem is this value locate inside a loop. example : the mean running script : m=0 # this function to return any value from

Re: [Tutor] How to notify/handle an error?

2010-10-31 Thread Alan Gauld
"dave p. guandalino" wrote Which of the following ways is better to handle something wrong? Its not really a questin of "better" but a question of more idiomatic. def is_valid_project(): # Do checks and valorize is_a_valid_project accordingly return is_a_valid_project # True / False

Re: [Tutor] File transfer

2010-10-31 Thread Corey Richardson
On 10/31/2010 12:06 PM, Chris King wrote: On 10/31/2010 12:03 PM, Corey Richardson wrote: On 10/31/2010 11:51 AM, Chris King wrote: On 10/30/2010 10:08 PM, Corey Richardson wrote: If you can send a list, have the list [name, data] where name is the file name and data is the raw binary of t

Re: [Tutor] File transfer

2010-10-31 Thread Chris King
On 10/31/2010 12:03 PM, Corey Richardson wrote: On 10/31/2010 11:51 AM, Chris King wrote: On 10/30/2010 10:08 PM, Corey Richardson wrote: If you can send a list, have the list [name, data] where name is the file name and data is the raw binary of the file, contained in a string. On 10/30/2

Re: [Tutor] decorators (the "at" sign)?

2010-10-31 Thread Siren Saren
Thanks for this very helpful post, Lie.  I find decorators quite interesting and am always looking for new ways to understand and use them.  Your trace function is fun, and I added it to my decorator library.  In response to your point about event-handling in GUIs: I haven't used pyqt that exte

Re: [Tutor] How to notify/handle an error?

2010-10-31 Thread Steven D'Aprano
Steven D'Aprano wrote: Never (well, *almost* never) use print for printing error messages. More information here: http://en.wikipedia.org/wiki/Error_hiding -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] (no subject)

2010-10-31 Thread Steven D'Aprano
Jacob Bender wrote: I have a few more ?'s. Well, don't keep them a secret, tell us what they are! What are your questions? I was trying to make a program for ubuntu that does one function: if ctrl + Alt + "t" is pressed, to shut down the computer. There are only two problems. I want it to

Re: [Tutor] How to notify/handle an error?

2010-10-31 Thread Steven D'Aprano
dave p. guandalino wrote: Which of the following ways is better to handle something wrong? Many thanks. It depends on what you are trying to do. # First: def is_valid_project(): # Do checks and valorize is_a_valid_project accordingly return is_a_valid_project # True / False Do you

[Tutor] (no subject)

2010-10-31 Thread Jacob Bender
I have a few more ?'s. I was trying to make a program for ubuntu that does one function: if ctrl + Alt + "t" is pressed, to shut down the computer. There are only two problems. I want it to run in the background, so nobody knows it's there. I do know how to make it run at startup, so that isn't a p

Re: [Tutor] (no subject)

2010-10-31 Thread Jacob Bender
Thanks, and I'm looking it over... On 10/30/10, Tino Dai wrote: > On Sat, Oct 30, 2010 at 6:44 PM, Jacob Bender > wrote: > >> Dear Tutors, >> >> I was wondering how I could make an AI for creatures that run >> around, and try to survive. Like polyworld. The real problem is making >> the code

[Tutor] How to notify/handle an error?

2010-10-31 Thread dave p. guandalino
Which of the following ways is better to handle something wrong? Many thanks. # First: def is_valid_project(): # Do checks and valorize is_a_valid_project accordingly return is_a_valid_project # True / False # caller side if is_valid_project(): pass # do stuffs with valid project else

Re: [Tutor] File transfer

2010-10-31 Thread Steven D'Aprano
Corey Richardson wrote: If you can send a list, have the list [name, data] where name is the file name and data is the raw binary of the file, contained in a string. How do you send a list? -- Steven ___ Tutor maillist - Tutor@python.org To unsub

Re: [Tutor] File transfer

2010-10-31 Thread Alan Gauld
"Chris King" wrote How would I send a file from one computer to another. I have modules which can send simple objects, such as dictionaries with simple objects in it. They can't send files thou. Please help. Can you use ftp? Thats the easiest way... Python has an ftp module. The only