Re: [Tutor] Best Practice: Subroutines and Loop logic

2009-09-03 Thread Alan Gauld
"GoodPotatoes" wrote #logic loop for word in lData: if word in lWords: continue elif sub1(word)[0]=1: word=sub1(word)[1] # <--- Here is my question. else: print word " not found.\n" The subroutine is being run once at the elif statement. I don't want to run it a

Re: [Tutor] Input validation

2009-09-03 Thread Alan Gauld
"Albert-Jan Roskam" wrote I'm wondering what is the most common method of input validation. Any and all of the methods will work in different situations but its generally best to use duck typing and try to write code that works for any type as far as possible. Then use exceptions to catc

Re: [Tutor] how to read and transmit/send only section of the image (sub-image)

2009-09-03 Thread Mac Ryan
On Fri, 2009-09-04 at 00:01 +0200, Jojo Mwebaze wrote: > thanks guys, > > > Currently i am using pyfits, a bit slow cause loads the file in > memory, creates a subimage and then saves the file then transmits > the file over the network! My idea is, if there is a way of creating > a file pointer

Re: [Tutor] Best Practice: Subroutines and Loop logic

2009-09-03 Thread Benno Lang
On Fri, Sep 4, 2009 at 3:29 AM, GoodPotatoes wrote: > Hello, > > I am trying to find the best way to do this.  My goal is to only call this > subroutine only ONCE, and the logic is contingent upon two outputs. > > lWords=[...] # List of many, many words > lData=[...] #list of some words that need t

Re: [Tutor] how to read and transmit/send only section of the image (sub-image)

2009-09-03 Thread Jojo Mwebaze
thanks guys, Currently i am using pyfits, a bit slow cause loads the file in memory, creates a subimage and then saves the file then transmits the file over the network! My idea is, if there is a way of creating a file pointer to the location on disk, where the subimage lies, reading a specific si

[Tutor] Processing a string of bytes

2009-09-03 Thread David Perlman
I have successfully used the builtin "wave" module to read an audio file in as a string of bytes: >>> x=wave.open('DaCWL.wav','rb') >>> x.getparams() (1, 2, 44100, 15440, 'NONE', 'not compressed') >>> samp=x.readframes(15440) >>> type(samp) The x.getparams() indicates that there is one audio

[Tutor] Best Practice: Subroutines and Loop logic

2009-09-03 Thread GoodPotatoes
Hello, I am trying to find the best way to do this. My goal is to only call this subroutine only ONCE, and the logic is contingent upon two outputs. lWords=[...] # List of many, many words lData=[...] #list of some words that need to be validated against lWords #subroutine to search for words,

Re: [Tutor] Having trouble with a dictionary of lists

2009-09-03 Thread Emile van Sebille
On 9/3/2009 11:01 AM William Witteman said... I am trying to create a CSV file of sorted similar lists, arranged so that differences are easily compared in a spreadsheet. I am encountering the following error, however: IndexError: list assignment index out of range On the indicated line below.

[Tutor] Having trouble with a dictionary of lists

2009-09-03 Thread William Witteman
I am trying to create a CSV file of sorted similar lists, arranged so that differences are easily compared in a spreadsheet. I am encountering the following error, however: IndexError: list assignment index out of range On the indicated line below. I understand the error, but I don't understand

[Tutor] Input validation

2009-09-03 Thread Albert-Jan Roskam
Hi, I'm wondering what is the most common method of input validation. See the example below. -Is the code below the most common/recognizable way something like this is done? -Which of the options #1 and #2 is the preferred method? Option #2 looks less esoteric, but #1 seems better when you have

Re: [Tutor] Tracking variable changes in a different application

2009-09-03 Thread Kristina Ambert
Hey guys, Yes, I figure that there are changes that need to be done in the main application to fit the needs of my application. Like what some of you guys suggested, I have looked into having the main application use a database to feed the information that I'll need. Right now that I guess is the

[Tutor] multiprocessing: Correct usage of pool & queue?

2009-09-03 Thread Allen Fowler
Hello, I have a list of tasks/items that I want handed off to threads/processes to complete. (I would like to stick with process if I could, since there is some CPU work here. ) Each task involves some calculations and a call to a remote server over urllib2/HTTP. The time to complete each

Re: [Tutor] how to read and transmit/send only section of the image (sub-image)

2009-09-03 Thread Kent Johnson
On Thu, Sep 3, 2009 at 9:05 AM, Jojo Mwebaze wrote: > Hello Tutor > > I am writing Class to provide data transfer between the server and client > processes based on simple HTTP GET/POST operations. However my interest is a > sub-image (section of a full image). i am requesting help on how to read a

Re: [Tutor] how to read and transmit/send only section of the image (sub-image)

2009-09-03 Thread Wayne
On Thu, Sep 3, 2009 at 8:05 AM, Jojo Mwebaze wrote: > Hello Tutor > > I am writing Class to provide data transfer between the server and client > processes based on simple HTTP GET/POST operations. However my interest is a > sub-image (section of a full image). i am requesting help on how to read

[Tutor] how to read and transmit/send only section of the image (sub-image)

2009-09-03 Thread Jojo Mwebaze
Hello Tutor I am writing Class to provide data transfer between the server and client processes based on simple HTTP GET/POST operations. However my interest is a sub-image (section of a full image). i am requesting help on how to read and transmit/send only section of the image (sub-image). i als

Re: [Tutor] running python program on Linux Virtual Server - Plesk?

2009-09-03 Thread Christian Witts
Michael Yang wrote: thanks. so this would run my script on a schedule i specify. And its a "set it and forget it" deal. but if i want to view the output of the program (ie. the program has various print statements to show program's status), how would I do this while its running the job? MI