Re: [Tutor] feeding data to subprocess exes and getting results without writing files

2007-01-11 Thread Barton David
Thanks Chris, I figured it out after a while.. import subprocess inputtext=my input string process=subprocess.Popen(myprog.exe -i stdin -o stdout,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.S TDOUT) outputtext,errortext=process.communicate(inputtext) ..so it is fairly simple

Re: [Tutor] string.uppercase: too many for locale

2007-01-11 Thread Barnaby Scott
Kent Johnson wrote: Barnaby Scott wrote: Can anyone explain the following: I was getting string.uppercase returning an unexpected number of characters, given that the Python Help says that it should normally be A-Z. Being locale-dependent, I checked that my locale was not set to something

[Tutor] Image Question, List of Image Colors

2007-01-11 Thread Carlos
Hello, Could someone who is familiar with image manipulation tell me what is the best way to obtain the list of colors inside an image? By best I'm referring to something that gets the job done in the fastest way, because this operation will be repeated a number of times. Thanks for your

[Tutor] Finding the key for a value in a dictionary.

2007-01-11 Thread Wesley Brooks
Dear Users, I'm trying to find the key of a unique value within a dictionary. Is the code bellow a safe way of doing so, or is there a better way of doing it? a = {'de':'df', 'gf':'hg'} key = a.keys()[a.values().index('hg')] Thanks for your help, Yours Faithfully, Wesley Brooks

[Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread raghu raghu
Hi everyone, I have a quick quick question joining out of order dictionary values. For example: I created an empty config={} Added some key/value pairs config[test1]=elem1 config[test2]=elem2 config[test3]=elem3 etc Dumped the values and joined them at the same time. print

Re: [Tutor] Finding the key for a value in a dictionary.

2007-01-11 Thread Kent Johnson
Wesley Brooks wrote: Dear Users, I'm trying to find the key of a unique value within a dictionary. Is the code bellow a safe way of doing so, or is there a better way of doing it? a = {'de':'df', 'gf':'hg'} key = a.keys()[a.values().index('hg')] This is safe, as long as the dict is not

Re: [Tutor] Finding the key for a value in a dictionary.

2007-01-11 Thread Wesley Brooks
Cheers for the reply. I'm creating a custom dictionary that I can use to store list of unique objects used in a GUI. Items are added then a unique string is returned. I have used this approach so if an item is deleted from the storage dictionary I can still find it using the key, where as if I

Re: [Tutor] string.uppercase: too many for locale

2007-01-11 Thread Kent Johnson
Barnaby Scott wrote: Thanks, but this raises various questions: I am in no way an expert on this, I am guessing...if anyone else knows for sure what is going on, please let me know! Why would my locale have 'changed' - and from what? The docs for the locale module say According to POSIX, a

[Tutor] Psyco Puzzle

2007-01-11 Thread Dick Moores
Sometimes psyco speeds up a script by a factor of 10, and sometimes it makes no difference at all. Here's a case where I fully expected it to make a difference: http://www.rcblue.com/Python/Psyco_Puzzle.txt. Whether using psyco or not, this takes about 13 seconds on my computer. Why no

Re: [Tutor] Image Question, List of Image Colors

2007-01-11 Thread Kent Johnson
Carlos wrote: Hello, Could someone who is familiar with image manipulation tell me what is the best way to obtain the list of colors inside an image? By best I'm referring to something that gets the job done in the fastest way, because this operation will be repeated a number of times.

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread Andre Engels
2007/1/11, raghu raghu [EMAIL PROTECTED]: print \\.join((config[val2],config[val1],config[val3])) elem2\elem1\elem3 or print %s\\%s\\%s % (config[val2],config[val1],config[val3]) elem2\elem1\elem3 but this seems somehow uneligent. Are there a more efficient/compact ways of doing this kind

[Tutor] Reminder: Early Bird Registration for PyCon Ending Soon

2007-01-11 Thread Jeff Rush
Greetings. As co-chair for the upcoming volunteer-run conference in the Dallas (Addison) area I would like to extend a *special* invitation to those just getting started with Python. PyCon is not just for the experts and this year we are making a special effort to reach out to those new to or

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread Andrew Robert
I like this solution. Thanks everyone for all of the suggestions. On 1/11/07, Andre Engels [EMAIL PROTECTED] wrote: 2007/1/11, raghu raghu [EMAIL PROTECTED]: print \\.join((config[val2] ,config[val1],config[val3])) elem2\elem1\elem3 or print %s\\%s\\%s %

[Tutor] Removing duplicates in a list with a fixed length of items in the list.

2007-01-11 Thread Adam Cripps
I have a list which comprises of simple random arithmetic problems for teachers to give to their pupils. This list must be a set length (if the teacher asks for 10 questions, they should get 10 questions), but should not have any duplicates. I've seen the use of sets, but this reduces the size of

Re: [Tutor] Removing duplicates in a list with a fixed length of items in the list.

2007-01-11 Thread Kent Johnson
Adam Cripps wrote: I have a list which comprises of simple random arithmetic problems for teachers to give to their pupils. This list must be a set length (if the teacher asks for 10 questions, they should get 10 questions), but should not have any duplicates. I've seen the use of sets, but

Re: [Tutor] Removing duplicates in a list with a fixed length of items in the list.

2007-01-11 Thread Adam Cripps
On 1/11/07, Adam Cripps [EMAIL PROTECTED] wrote: On 1/11/07, Kent Johnson [EMAIL PROTECTED] wrote: Adam Cripps wrote: I have a list which comprises of simple random arithmetic problems for teachers to give to their pupils. This list must be a set length (if the teacher asks for 10

Re: [Tutor] Removing duplicates in a list with a fixed length of items in the list.

2007-01-11 Thread Kent Johnson
Adam Cripps wrote: I've not worked with Sets before but will give it a go. Is there a way of turning the Set back to a list? list(mySet) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Image Question, List of Image Colors

2007-01-11 Thread Carlos
Hello, I'm trying to do what Kent suggested, but I have a little problem, no matter were I put my image or if I use sys.path.append to append the folder were my Image is located it is impossible to open the image. I know that this is a silly question but what is going on? I like to solve

[Tutor] Converting a string to a list with each character as an item

2007-01-11 Thread Amadeo Bellotti
does anyone know how to do this? I need it because i want to make a binary coverter ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Converting a string to a list with each character as an item

2007-01-11 Thread Terry Carroll
On Thu, 11 Jan 2007, Amadeo Bellotti wrote: does anyone know how to do this? I need it because i want to make a binary coverter s = 101001100100101 l = list(s) l ['1', '0', '1', '0', '0', '1', '1', '0', '0', '1', '0', '0', '1', '0', '1'] ___

Re: [Tutor] Psyco Puzzle

2007-01-11 Thread Danny Yoo
Sometimes psyco speeds up a script by a factor of 10, and sometimes it makes no difference at all. Here's a case where I fully expected it to make a difference: http://www.rcblue.com/Python/Psyco_Puzzle.txt. Whether using psyco or not, this takes about 13 seconds on my computer. Why no

Re: [Tutor] python web dev

2007-01-11 Thread Hugo González Monteverde
OkaMthembo wrote: this is my first post. please could you tell me which is the best lightweight python web framework? also, which is the best templating language for python? (which can handle other data formats in addition to text). so far im lured by Cheetah, although i havent done any

Re: [Tutor] problems pickling functions

2007-01-11 Thread Hugo González Monteverde
Arild B. Næss wrote: I haven't found out how to change the working directory in IDLE, though – and for some reason it seems to be a different one this session from the last one. Does anyone know? (I use a mac by the way.) take a look at os.chdir() This changes the interpreter's

Re: [Tutor] XML-RPC data transfers.

2007-01-11 Thread Hugo González Monteverde
Luke Paireepinart wrote: But the main strategy is to get the data out of the ImageGrab object. one way is stated above - use the save method to write to a file. another possible way is to create a filelike class, implementing 'tell' 'seek' and 'write' methods, that just collects all the

Re: [Tutor] Python and rpy

2007-01-11 Thread Hugo González Monteverde
Geoframer wrote: However i switched to Ubuntu 6.10 today (from WinXP) and to my suprise it does work under linux! :-) Probably Numeric is included in Ubuntu's Python distro. Hugo ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread Luke Paireepinart
raghu raghu wrote: [snip original message] To print or to retain individual values from a list,it has to be written in the form of config={'test1':'elem1','test2':'elem2','test3':'elem3'} config['test4'] = 'elem4' print config.values() print config['test1']- To get individual values

Re: [Tutor] Image Question, List of Image Colors

2007-01-11 Thread Danny Yoo
I'm trying to do what Kent suggested, but I have a little problem, no matter were I put my image or if I use sys.path.append to append the folder were my Image is located it is impossible to open the image. I know that this is a silly question but what is going on? sys.path contains a list

Re: [Tutor] Image Question, List of Image Colors

2007-01-11 Thread Luke Paireepinart
Carlos wrote: Hello, I'm trying to do what Kent suggested, but I have a little problem, no matter were I put my image or if I use sys.path.append to append the folder were my Image is located it is impossible to open the image. I know that this is a silly question but what is going on?

Re: [Tutor] Converting a string to a list with each character as an item

2007-01-11 Thread Danny Yoo
On Thu, 11 Jan 2007, Terry Carroll wrote: On Thu, 11 Jan 2007, Amadeo Bellotti wrote: does anyone know how to do this? I need it because i want to make a binary coverter s = 101001100100101 l = list(s) l ['1', '0', '1', '0', '0', '1', '1', '0', '0', '1', '0', '0', '1', '0', '1'] By

Re: [Tutor] Converting a string to a list with each character as an item

2007-01-11 Thread Bob Gailer
Amadeo Bellotti wrote: does anyone know how to do this? I need it because i want to make a binary coverter list('abc') ['a', 'b', 'c'] -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Image Question, List of Image Colors

2007-01-11 Thread Carlos
Hello, Well seems like Danny was right, the backslashes were the problem! This really got an 11 in my frustration meter. Thanks for your help Carlos ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] more fun and games with padded numbers

2007-01-11 Thread Christopher Spears
Let's say I have a series of files that are named like so: 0001.ext 0230.ext 0041.ext 0050.ext How would I convert these from a padding of 4 to a padding of 1? In other words, I want the files to be renamed as: 1.ext 230.ext 41.ext 50.ext At first I used strip(), which was a mistake because

Re: [Tutor] more fun and games with padded numbers

2007-01-11 Thread John Fouhy
On 12/01/07, Christopher Spears [EMAIL PROTECTED] wrote: Let's say I have a series of files that are named like so: 0001.ext 0230.ext 0041.ext 0050.ext How would I convert these from a padding of 4 to a padding of 1? In other words, I want the files to be renamed as: 1.ext 230.ext

Re: [Tutor] Removing duplicates in a list with a fixed length of items in the list.

2007-01-11 Thread Klaus Ramelow
Why not sorting the items and throw out all multiples until you reach the fixed length ? Klaus Ramelow ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] more fun and games with padded numbers

2007-01-11 Thread Terry Carroll
On Thu, 11 Jan 2007, Christopher Spears wrote: Let's say I have a series of files that are named like so: 0001.ext 0230.ext 0041.ext 0050.ext How would I convert these from a padding of 4 to a padding of 1? In other words, I want the files to be renamed as: 1.ext 230.ext 41.ext