944,055 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 35101
  • Python RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 25th, 2005
0

Compiling .py files...

Expand Post »
Hi..

Ive been doing python for about 2 days now (my 1st programming language) and im wondering, after ive made the .py file, and all the codes in it, how do i run it?

To be honest im not even sure if the term compiling is right...

I am doing all of the work on Fedora Core 3 (im also new to linux. lol, though im not a computer noob, i do know my way around one )

anyways, can anyone give me a link to a website, another post explaining this, or even explain it?

Ty in advance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Fallen05 is offline Offline
4 posts
since Jun 2005
Jun 25th, 2005
0

Re: Compiling .py files...

AFAIK, python just works, something like Perl just works, no need to compile

You do need a way to run python however
Team Colleague
Reputation Points: 96
Solved Threads: 21
The Geek Father
Zachery is offline Offline
781 posts
since Nov 2003
Jun 25th, 2005
0

Re: Compiling .py files...

Quote originally posted by Zachery ...
AFAIK, python just works, something like Perl just works, no need to compile

You do need a way to run python however
Need a way to run python? huh? lol, re-phrase plz -.-

and as for "python just works" how do i run .py files as a program? o.O

Eg. i have helloworld.py saved in /usr/bin/
what command do i run to run it as a program, and i also want to have it run as an executable...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Fallen05 is offline Offline
4 posts
since Jun 2005
Jun 25th, 2005
0

Re: Compiling .py files...

A command like Python.exe Filename.py will do. It is simpler to run it from an editor/IDE like IDLE, see the "Starting Python" sticky right here.

On Windows, once you have installed Python, any .py file is associated with Python.exe, so you just double click on the .py file. I don't work with Linux, there should be a command of some kind.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jun 25th, 2005
0

Re: Compiling .py files...

lol, maby i should just learn C r sumthin, ive been told its too hard as a 1st language tho *-*
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Fallen05 is offline Offline
4 posts
since Jun 2005
Jun 25th, 2005
0

Re: Compiling .py files...

C isn't hard to learn! It works well in the trenches. It only gets hard, if you want to program something fancy.

Python works at a much higher level, this simply means that a lot of things you will be coding in C many pages long is ready to go in a Python module (some of it written in C). Walking on foot, flying in a jetplane, each has its purpose.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jun 25th, 2005
0

Re: Compiling .py files...

hmm........
lol, though switching to a different language is gona give me all the same problems again *-* lol, ill have to find out how to compile .c files, and all that poo -.-

lol, though i supposes its the most worth while learning, so, know any good tuts? (That includes compiling the files.. through unix/linux terminal)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Fallen05 is offline Offline
4 posts
since Jun 2005
Jun 27th, 2005
0

Re: Compiling .py files...

There is a Python online book/tutorial at:
http://www.byteofpython.info/
that is for the very beginner and addresses Python programming in the linux environment too.

The first step, be it Python or C, is a little steep. It's like learning to ride a bike. Try the tutorial or find someone in school that has done programming. Who knows, even a teacher or two may know.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jun 27th, 2005
0

Re: Compiling .py files...

if your file is in /usr/bin and the file starts with
#!/usr/bin/python
the above method assumes you have python install in /usr/bin or better yet
#!/usr/bin/env python
this method will run it no matter where you installed python

you just need to make the file executable with the command
Python Syntax (Toggle Plain Text)
  1. chmod +x /usr/bin/hello.py
now you can just run it by entering its command hello.py. This will work because /usr/bin is in your normal path. If you had the program somewhere else like your home directory. you would need to type the whole path, /home/fallen/hello.py

It is not probably a good habit to be putting test programs in /usr/bin. It should not cause problems, but will make a mess of that directory. I myself have a python directory in my home directory

you also could ignore everything I said above and do it this way. type the command python then the location of the file
Python Syntax (Toggle Plain Text)
  1. python hello.py
the above method will work if you are in the same directory as the program. else do it like this
Python Syntax (Toggle Plain Text)
  1. python /full/path/to/hello.py
Reputation Points: 10
Solved Threads: 17
Posting Whiz in Training
shanenin is offline Offline
217 posts
since May 2005
Nov 18th, 2005
0

Re: Compiling .py files...

Hi Friends,
I am new to Python programming. I had been given a simple project using c & python.The Project goes like this "To give .c and .py file's outputs as input to another .c file which should give single output". so please post ur valuable Solutions. My mail-id is krishnamohan516@yahoo.com.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
krishnamohan516 is offline Offline
1 posts
since Nov 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Square Root Madness...
Next Thread in Python Forum Timeline: Multi Dimentional Array in Python





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC