Python 3 minor irritation

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Feb 4 19:03:20 EST 2010


En Thu, 04 Feb 2010 17:50:29 -0300, Gib Bogle  
<g.bogle at auckland.no.spam.ac.nz> escribió:
> Gabriel Genellina wrote:

>>  Also, from the command line, execute:
>>  D:\temp>reg query HKCR\.py
>>  ! REG.EXE VERSION 3.0
>>  HKEY_CLASSES_ROOT\.py
>>     <Sin nombre>        REG_SZ  Python.File
>>     Content Type        REG_SZ  text/plain
>>  HKEY_CLASSES_ROOT\.py\PersistentHandler
>
> I'm interested in this, because I'm using Windows XP, and when I execute  
> this command I see the first part but not the second (with  
> PersistentHandler).

Sorry, I should have removed that line. This is just my setup; a normal  
Python install doesn't create that registry entry. It allows Desktop  
Search (or Windows Search, or whatever it is called nowadays; the F3 key)  
to search inside .py files (default behavior is to just ignore their  
contents).
See http://support.microsoft.com/kb/309173

> Is this related to the fact that when I double-click on a .py file the  
> command window disappears after the execution is completed?

(I bet the "Persistent" word confused you.) No, as you can see, it's  
completely unrelated. AFAIK, there is no way (on XP and later at least) to  
keep a console window open after the program exited. Three choices:

- Open a cmd window and execute the script there. You may drag&drop the  
file over the window to avoid typing the full path (I think this last part  
does not work on Vista nor Win7)

- Add a raw_input() [2.x] or input() [3.x] line at the end of the script

- Rename it with a '.cmd' extension and add this line at the very top:

	@(C:\Python26\Python -x %~f0 %* || pause) && goto:EOF

(see this post by Duncan Booth last month:
http://comments.gmane.org/gmane.comp.python.general/650913 )

-- 
Gabriel Genellina




More information about the Python-list mailing list