Hello,
is there a way to compile a python file foo.py to foo.pyc (or foo.pyo)
such that foo.pyc can be run with 'foo.pyc' (as opposed to 'python
foo.pyc') on the command line?
Jörg Schuster 11 2309
Is there some reason why you want to run the .pyc file, rather than the
..py file? If you start the script with
#! /usr/bin/env python
Then if the file has the execution permission set, typing the file name
(foo.py) will make the script call up the Python interpreter on its
own.
On 26 Apr 2005 18:15:51 -0700, jo************* *@gmail.com
<jo************ **@gmail.com> wrote: Is there some reason why you want to run the .pyc file, rather than the .py file? If you start the script with
a. It's more efficient, since the code doesn't need to be compiled
before it's run.
b. What if you want to ship closed-source?
Mike
--
Michael P. Soulier <ms******@gmail .com> http://www.digitaltorque.ca http://opag.ca python -c 'import this'
Michael Soulier wrote: Is there some reason why you want to run the .pyc file, rather than the .py file? If you start the script with
a. It's more efficient, since the code doesn't need to be compiled before it's run. b. What if you want to ship closed-source?
#!/usr/bin/env python
import app
hardly qualifies as "hard to compile" or "open source"
</F>
> #!/usr/bin/env python import app
Yes, of course this is a possibility. But it implies having (or giving
away) two files.
I think having one file is always better than having two files. Because
if you have two files, you need a third one: a README that tells you
what to do with the two files and that one of the files must either be
in $PYTHONPATH, or in the same directory as the other one and '.' must
be in your $PYTHONPATH , and so on. Actually, some people will also
need a fourth file: One that contains an explanation of terms like
"$PYTHONPAT H" and the like.
Jörg
I just happened across the page linked to below, and remembered this
thread, and, well... here you go: http://www.lyra.org/greg/python/
Executable .pyc files
Ever wanted to drop a .pyc file right into your web server's
cgi-bin directory? Frustrated because the OS doesn't know what to do
with a .pyc? (missing the #! line)
Look no further! :-) Below is a tiny Bash script to do this. "cat"
your .pyc onto the end of this and drop it wherever you need direct
execution of that .pyc
On Wed, 27 Apr 2005 10:37:11 -0400, Michael Soulier <ms******@gmail .com>
declaimed the following in comp.lang.pytho n: a. It's more efficient, since the code doesn't need to be compiled before it's run. b. What if you want to ship closed-source?
You stuff the real code into a module that gets imported (hence
cached as a .pyc), and the main program in source looks like:
import thedirtystuff
thedirtystuff.m ain()
-- =============== =============== =============== =============== == < wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < =============== =============== =============== =============== == < Home Page: <http://www.dm.net/~wulfraed/> < Overflow Page: <http://wlfraed.home.ne tcom.com/> <
Joerg Schuster wrote: #!/usr/bin/env python import app Yes, of course this is a possibility. But it implies having (or giving away) two files.
yeah, think of all the disk space you'll waste!
Because if you have two files, you need a third one: a README that tells you what to do with the two files
so you're saying that the set of people that can deal with no more than one
file at a time but knows how to install and configure Python (which in itself
comes with a few thousand files) is larger than zero?
I think having one file is always better than having two files.
so you don't ever use modules?
you haven't distributed many Python programs, have you?
</F>
On 2005-04-27, Fredrik Lundh <fr*****@python ware.com> wrote: so you're saying that the set of people that can deal with no more than one file at a time but knows how to install and configure Python (which in itself comes with a few thousand files) is larger than zero?
There are a lot of Linux users who already have python
installed but don't know it. Python was always a required package for
a RedHat install. It's not required on some distros, but it's
installed by default and you've got to go out of your way to
de-selected it when you install.
I've found that giving Linux users a single file "executable "
Python script works wonderfully, but it's really only an option
for fairly small applications -- and I don't care if they have
source code.
--
Grant Edwards grante Yow! Look!! Karl Malden!
at
visi.com
Fredrik Lundh wrote: Joerg Schuster wrote:
> #!/usr/bin/env python > import app
Yes, of course this is a possibility. But it implies having (or giving away) two files.
yeah, think of all the disk space you'll waste!
Because if you have two files, you need a third one: a README that tells you what to do with the two files
so you're saying that the set of people that can deal with no more than one file at a time but knows how to install and configure Python (which in itself comes with a few thousand files) is larger than zero?
On Windows, installing Python takes only a few clicks. No brain cycles
needed ;) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: deko |
last post by:
In regard to running php scripts with cron -
Here is a sample script:
<?php
//debug.php
echo "<br> This is a test";
?>
I can call debug.php from a web page on my site like this:
|
by: Chris Lasher |
last post by:
Should a Python module not intended to be executed have shebang/
hashbang (e.g., "#!/usr/bin/env python") or not? I'm used to having a
shebang in every .py file but I recently heard someone argue that
shebangs were only appropriate for Python code intended to be
executable (i.e., run from the command line).
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |