473,382 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Need compile python code

Need compile python code, source is in html and starts with parameters:

#!/bin/sh -
"exec" "python" "-O" "$0" "$@"

I have installed ActivePython for windows.

Sep 23 '06 #1
14 5470
mistral wrote:
Need compile python code, source is in html and starts with
parameters:
Excuse me?
#!/bin/sh -
"exec" "python" "-O" "$0" "$@"
Is the line break intended?
I have installed ActivePython for windows.
What exactly do you want?

Python code is always compiled (to byte code) before it's run.

Regards,
Bjrn

--
BOFH excuse #359:

YOU HAVE AN I/O ERROR -Incompetent Operator error

Sep 23 '06 #2

Bjoern Schliessmann писал(а):
mistral wrote:
Need compile python code, source is in html and starts with
parameters:

Excuse me?
#!/bin/sh -
"exec" "python" "-O" "$0" "$@"

Is the line break intended?
I have installed ActivePython for windows.

What exactly do you want?

Python code is always compiled (to byte code) before it's run.

Regards,
Björn

--
Just to comple python ode - it creates html page, nothing more, nothing
else.. Just generate one html page.

mistral

Sep 23 '06 #3

Bjoern Schliessmann писал(а):
mistral wrote:
Need compile python code, source is in html and starts with
parameters:

Excuse me?
#!/bin/sh -
"exec" "python" "-O" "$0" "$@"

Is the line break intended?
I have installed ActivePython for windows.

What exactly do you want?

Python code is always compiled (to byte code) before it's run.

Regards,
Björn

--
Just to comple python ode - it creates html page, nothing more, nothing
else.. Just generate one html page.

mistral

Sep 23 '06 #4
mistral wrote:
Just to comple python ode - it creates html page, nothing more, nothing
else.. Just generate one html page.
I *think* this is what you want:

python -O -m py_compile file.py
python file.pyo

See: http://docs.python.org/lib/module-pycompile.html

Regards,
Jordan

Sep 23 '06 #5

MonkeeSage писал(а):
mistral wrote:
Just to comple python ode - it creates html page, nothing more, nothing
else.. Just generate one html page.

I *think* this is what you want:

python -O -m py_compile file.py
python file.pyo

See: http://docs.python.org/lib/module-pycompile.html

Regards,
Jordan
----------
this not work for me, show compilation error. Is there simple way
compile pythone file? its absolutely unclear with command line. Just
show me exact command I need run(from python interactive shell?)

Sep 23 '06 #6
mistral wrote:
this not work for me, show compilation error. Is there simple way
compile pythone file? its absolutely unclear with command line. Just
show me exact command I need run(from python interactive shell?)
OK...

# cd to where the file.py is
$ cd /some/dir

# start python interactively, enable optimized compiling
$ python -O
....

# import your file.py -- if this doesn't work then
# your file has errors and will not compile --
# if it works then your file is now compiled --
# file.pyo should now exist with file.py
>>import file
# you can also do it explicitly --
# import the compiler
>>import py_compile
py_compiler.compile('file.py')
If that still doesn't work, show us the error, or we can't help you
very easily.

Regards,
Jordan

Sep 23 '06 #7
MonkeeSage wrote:
>import py_compile
py_compiler.compile('file.py')
^^^^^^^^^^^

Should be:
>>py_compile.compile('file.py')
Sep 23 '06 #8

MonkeeSage wrote:
mistral wrote:
this not work for me, show compilation error. Is there simple way
compile pythone file? its absolutely unclear with command line. Just
show me exact command I need run(from python interactive shell?)

OK...

# cd to where the file.py is
$ cd /some/dir

# start python interactively, enable optimized compiling
$ python -O
...

# import your file.py -- if this doesn't work then
# your file has errors and will not compile --
# if it works then your file is now compiled --
# file.pyo should now exist with file.py
>import file

# you can also do it explicitly --
# import the compiler
>import py_compile
py_compiler.compile('file.py')

If that still doesn't work, show us the error, or we can't help you
very easily.

Regards,
Jordan
---

No, something is wrong there. what I need is just compile one python
file which will generate html page, with parameters:
"exec" "python" "-O" "$0" "$@"

just need simple way do this(script is correct), i will not set any
patches anywhere, can i do this wrom normal GUI?

Sep 23 '06 #9
On 23 Sep 2006 12:24:58 -0700, mistral wrote
No, something is wrong there. what I need is just compile one python
file which will generate html page, with parameters:
"exec" "python" "-O" "$0" "$@"
This is not a python script. It appears to be a Unix shell script that calls a
python script.

Maybe it would help if you told us exactly what you're trying to accomplish
and why you think you need to "compile python code".

-Carsten

Sep 23 '06 #10
mistral wrote:
No, something is wrong there. what I need is just compile one python
file which will generate html page, with parameters:
"exec" "python" "-O" "$0" "$@"

just need simple way do this(script is correct), i will not set any
patches anywhere, can i do this wrom normal GUI?
Hmmm... Are you talking about _RUNNING_ python scripts? Is that what
you mean by "compile" -- you mean execute? Is that what this broken
shell script means?

"exec" "python" "-O" "$0" "$@"

You don't need exec, the double quote on every word breaks it, and
passing $0 (which is the shell script itself) to python is sure to
break. Try this:

#!/bin/sh
python -O "$@"

Then:

$ run_python.sh file.py arg1 arg2 arg3

Regards,
Jordan

Sep 23 '06 #11

MonkeeSage писал(а):
mistral wrote:
No, something is wrong there. what I need is just compile one python
file which will generate html page, with parameters:
"exec" "python" "-O" "$0" "$@"

just need simple way do this(script is correct), i will not set any
patches anywhere, can i do this wrom normal GUI?

Hmmm... Are you talking about _RUNNING_ python scripts? Is that what
you mean by "compile" -- you mean execute? Is that what this broken
shell script means?

"exec" "python" "-O" "$0" "$@"

You don't need exec, the double quote on every word breaks it, and
passing $0 (which is the shell script itself) to python is sure to
break. Try this:

#!/bin/sh
python -O "$@"

Then:

$ run_python.sh file.py arg1 arg2 arg3

Regards,
Jordan
-------
the html page just encoded within that py script. To get it, i need run
this python file.
Since i can no work with this command line, i tried via Python IDE
interface: I run this IDE, select File Run specify file name, in
'Parameters' box type parameters:

exec python -O $0 $@

and run. I got some file in output - unknown file type, then I renamed
it and got something look like a page i need. Dont know is this right
way or not, but it provided some result.. (unlike useless command line
interface)
All this extremelly inconvenient however. This ActivePython wrote in my
Registry 243 registry entries..

mistral

Sep 23 '06 #12

mistral wrote:
<various_othersписал(а):
There seems to be a rather large communication gap. Consider asking
your question in a Russian-speaking Python-related forum, for example:
http://zope.net.ru/

Regards,
John

Sep 23 '06 #13
>>>>"MonkeeSage" <Mo********@gmail.com(M) wrote:
>Mmistral wrote:
>>No, something is wrong there. what I need is just compile one python
file which will generate html page, with parameters:
"exec" "python" "-O" "$0" "$@"

just need simple way do this(script is correct), i will not set any
patches anywhere, can i do this wrom normal GUI?
>MHmmm... Are you talking about _RUNNING_ python scripts? Is that what
Myou mean by "compile" -- you mean execute? Is that what this broken
Mshell script means?
>M"exec" "python" "-O" "$0" "$@"
>MYou don't need exec, the double quote on every word breaks it, and
Mpassing $0 (which is the shell script itself) to python is sure to
Mbreak. Try this:
I guess this is a trick to use a python script as a shell script that
executes itself. In other words it is both a shell script and a python
script and when executed as a shell script then it passes itself to the
python interpreter. When executed as a python script the first line is a
comment and the second line is a string (equal to 'execpython-O$0$@'), so
both are skipped.

You can't use that in windows, or maybe there is an equivalent trick.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: pi**@vanoostrum.org
Sep 25 '06 #14

Piet van Oostrum писал(а):
>>>"MonkeeSage" <Mo********@gmail.com(M) wrote:
Mmistral wrote:
>No, something is wrong there. what I need is just compile one python
file which will generate html page, with parameters:
"exec" "python" "-O" "$0" "$@"

just need simple way do this(script is correct), i will not set any
patches anywhere, can i do this wrom normal GUI?
MHmmm... Are you talking about _RUNNING_ python scripts? Is that what
Myou mean by "compile" -- you mean execute? Is that what this broken
Mshell script means?
M"exec" "python" "-O" "$0" "$@"
MYou don't need exec, the double quote on every word breaks it, and
Mpassing $0 (which is the shell script itself) to python is sure to
Mbreak. Try this:

I guess this is a trick to use a python script as a shell script that
executes itself. In other words it is both a shell script and a python
script and when executed as a shell script then it passes itself to the
python interpreter. When executed as a python script the first line is a
comment and the second line is a string (equal to 'execpython-O$0$@'), so
both are skipped.

You can't use that in windows, or maybe there is an equivalent trick.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: pi**@vanoostrum.org
-----------

anyway, this is a wrong and clumsy way writing of scripts, rather than
write clear and correct code comfortable to work.

mistral

Sep 25 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris McKeever | last post by:
I am trying to modify the Mailman Python code to stop mapping MIME-types and use the extension of the attachment instead. I am pretty much clueless as to what I need to do here, but I think I have...
5
by: beliavsky | last post by:
How do you keep Python code properly indented as you modify it? I use an Emacs-type editor that has a Python mode, so the initial indenting is easy. If I later want to put a 'for' loop (or an 'if'...
6
by: nell | last post by:
Hi all, I've developed a testing application in python, and should supply it in a way that no one (lets say they are regular users) will understand it and edit it. The application source is all...
2
by: Charles | last post by:
Dear sirs, I'm doing some investigations on the Python language. I'd like to know if it is possible to compile Python code made for the web (an online database for instance), and to run it using...
64
by: Bayazee | last post by:
hi can we hide a python code ? if i want to write a commercial software can i hide my source code from users access ? we can conver it to pyc but this file can decompiled ... so ...!! do you...
1
by: Nader Emami | last post by:
L.S., I have to compile (install) locally Python 2.5, because I don't have 'root' permission. Besides I would use 'sqlite3' as a database for TurboGears/Django. I have installed 'sqlite3'...
3
by: Mitko Haralanov | last post by:
For various reason, what I need to do is be able to send some Python code (mostly entire functions in the form of a string) to a remote server (written in Python), have that server compile the code...
2
by: vijay | last post by:
Hi I have a python code performing some computation for me.I have a html page which passes certain argumnets to a php page.This php page needs to pass on the value to the Python class and get the...
2
by: John Nagle | last post by:
koblas wrote: PyPy was supposed to help, but that project has been dragging on for half a decade now. Personally, I think the Shed Skin approach is more promising. PyPy has too many different...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.