Re: [Tutor] range() help
On Tuesday 17 April 2007 14:42:50 [EMAIL PROTECTED] wrote: > >>> range(-10, -100, -30) > > [-10, -40, -70] > > How come it prints on -40 or -70. > > Does -70 come from -70 -> -100? > from -10 to -100 (excluding -100) -10-30 = -40 -40-30= -70 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] StringIO and dictionaries
I want to run an external python script inside my script. So here is what I came up with: Print codename for testing purposes. Define an empty dictionary. Read the file. Do StringIO assignments and run the code. Get the outputs and append them to the dictionary. Print the outputs for testing purposes. The code: codeOut= {} codeErr= {} Print codename for testing purposes: print codename Note: codename is a parameter that is passed to the function for the first parts (keys) of codeOut and codeErr dictionaries; and it prints the given name (deneme in this case) correctly. Read the file: localfile= open(filename,'r') code2run= localfile.readlines() localfile.close() Do StringIO assignments and run the code: codOut= StringIO.StringIO() codErr= StringIO.StringIO() sys.stdout= codOut sys.stderr= codErr exec code2run sys.stdout= sys.__stdout__ sys.stderr= sys.__stderr__ Get the outputs and append them to the dictionary. erroroutput= codErr.getvalue() normaloutput= codOut.getvalue() codeOut.append({codename:erroroutput}) codeErr.append({codename:normaloutput}) Print the outputs (just for testing): print codename print normaloutput print erroroutput print codeOut print codeErr And I get nothing. Is there something I am doing wrong? Because I have read the parts on dictionaries and stringio and googled, but I can't find the problem. Any comments, suggestions? Or could someone please tell me if there is something wrong with my code? -- Necmettin Begiter Blog: http://begiter.blogspot.com/feeds/posts/default ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Why is this not working? Seems like a whitespace issue
05 Şub 2007 Pts 04:58 tarihinde, Gizmo şunları yazmıştı: > Hello > I have a whole directory tree of RAR files that I wish to extract as a > batch job. In my real script I've used os.walk() and os.spawn*() but for > demonstration purposes have a look at the code below > > >>> import os > >>> process=r"C:\Program Files\WinRAR\Rar.exe" > >>> startDir = r"C:\to burn" > >>> > >>> os.system(process+" x "+"C:\\to burn\\somemovie\\mymovie.rar"+" > > "+startDir) > > This doesnt work for me.. I get the error " 'C:\Program' is not recognized > as an internal or external command, operable program or batch file." > Notice that it says "C:\Program" thats the incorrect path, the path is > supposed to be "C:\Program Files\..." > > I realised the problem definitely because of the space between "Program" > and "Files".. > Actually, I even know the solution to an extend. In Windows command prompt, > whenever you have whitespaces in your path, you are expected to enclose the > whole path in double quotes; for example: > > C:\>rar.exe x "C:\to burn\blah blah\" > > I think this is the reason, but I am unsure. Your support is greatly > appreciated. > > Thanks! Do you actually need the strings to be "raw"? (r"") Converting those strings to normal strings, you could easily make sure the space character (#32) is taken into account by escaping it: process= "c:\\Program\ files\\WinRar\Rar.exe" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Can I pause, stop or reset python virtual machine
05 Şub 2007 Pts 04:56 tarihinde, Wong Vincent şunları yazmıştı: > Dear tutors, > Hi. Does python provide any API to pause, stop or reset the virtual > machine? Am currently building an application which will run a script file > using os.popen(). In order to allow user to run, stop and pause the > application, is it advisable to do the abovementioned? or is there any > better way of doing it? In your "virtual machine", are you asking the user for a filename? Because if you are, if you have a dialog or whatever that asks the user for a filename, that point is where the "virtual machine" waits. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor