start .pyo files with doubleclick on windows

N

News123

Hi,


I'd like to start .pyo files under windows with a double click.
(I know I can just write a .bat wrapper, but somehow it would be more
fun to start with a direct double click)


Currently this works if the file does not import any other .pyo file.


The problem is, that a dobleclick performs a
"python.exe myfile.pyo"

In order to import precompiled .pyo files however it seems, that
"python.exe -OO myfile.pyo"

would be required.


Is there any trick to do this under windows?
The only trick, that I can think of is to write a small wrapper
executable, that would then call python -OO.


Wouldn't it be useful if python searched also for .pyo files when trying
to import and being invoked with

"python.exe mycode.pyo"


thanks in advance for any ideas suggestion
 
A

Alf P. Steinbach

* News123:
Hi,


I'd like to start .pyo files under windows with a double click.
(I know I can just write a .bat wrapper, but somehow it would be more
fun to start with a direct double click)


Currently this works if the file does not import any other .pyo file.


The problem is, that a dobleclick performs a
"python.exe myfile.pyo"

In order to import precompiled .pyo files however it seems, that
"python.exe -OO myfile.pyo"

would be required.


Is there any trick to do this under windows?
The only trick, that I can think of is to write a small wrapper
executable, that would then call python -OO.


Wouldn't it be useful if python searched also for .pyo files when trying
to import and being invoked with

"python.exe mycode.pyo"


thanks in advance for any ideas suggestion


C:\> assoc .pyo
..pyo=Python.CompiledFile

C:\> ftype python.compiledfile
python.compiledfile="C:\Program Files\cpython\python31\python.exe" "%1" %*

C:\> _


Use ftype to change the association.


Cheers & hth.,

- Alf
 
N

News123

Hi Alf,




* News123:

C:\> assoc .pyo
.pyo=Python.CompiledFile

C:\> ftype python.compiledfile
python.compiledfile="C:\Program Files\cpython\python31\python.exe" "%1" %*

C:\> _


Use ftype to change the association.

Thanks a lot, I leared something new about Windows


What I did now is this:

assoc .pyo=Python.CompiledOptimizedFile
ftype Python.CompiledOptimizedFile="C:\Python26\python.exe" -OO "%1" %*

bye

N
 
G

Gabriel Genellina

Hi Alf,






Thanks a lot, I leared something new about Windows


What I did now is this:

assoc .pyo=Python.CompiledOptimizedFile
ftype Python.CompiledOptimizedFile="C:\Python26\python.exe" -OO "%1" %*

This looks like a bug (or two)

- "python foo.pyo" should fail; a .pyo has a different magic number than a
..pyc file. Importing a .pyo file fails in this case. A .pyo file should be
run with "python -O foo.pyo" (or -OO)

- on Windows, .pyo files should be associated with python -O by default,
you should not need to do that by yourself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top