Compiling .py files...

Reply

Join Date: Jun 2005
Posts: 4
Reputation: Fallen05 is an unknown quantity at this point 
Solved Threads: 0
Fallen05 Fallen05 is offline Offline
Newbie Poster

Compiling .py files...

 
0
  #1
Jun 25th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 781
Reputation: Zachery has a spectacular aura about Zachery has a spectacular aura about 
Solved Threads: 21
Team Colleague
Zachery's Avatar
Zachery Zachery is offline Offline
The Geek Father

Re: Compiling .py files...

 
0
  #2
Jun 25th, 2005
AFAIK, python just works, something like Perl just works, no need to compile

You do need a way to run python however
Firefox: no, its not the end all solution, it has its own issues and in time it will be just as insecure as IE, when its hit Firefox 6, if it makes it that far. Oh, and AOL pays for it, incase you didn't know.

Microsoft & Windows: If you hate it so much, move to linux, or bsd, or anything else, stop complaning and move on.
Good starting places: Gentoo Novell SUSE Fedora Core Apple
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: Fallen05 is an unknown quantity at this point 
Solved Threads: 0
Fallen05 Fallen05 is offline Offline
Newbie Poster

Re: Compiling .py files...

 
0
  #3
Jun 25th, 2005
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...
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,009
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 928
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Compiling .py files...

 
0
  #4
Jun 25th, 2005
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.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: Fallen05 is an unknown quantity at this point 
Solved Threads: 0
Fallen05 Fallen05 is offline Offline
Newbie Poster

Re: Compiling .py files...

 
0
  #5
Jun 25th, 2005
lol, maby i should just learn C r sumthin, ive been told its too hard as a 1st language tho *-*
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,009
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 928
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Compiling .py files...

 
0
  #6
Jun 25th, 2005
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.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: Fallen05 is an unknown quantity at this point 
Solved Threads: 0
Fallen05 Fallen05 is offline Offline
Newbie Poster

Re: Compiling .py files...

 
0
  #7
Jun 25th, 2005
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)
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,009
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 928
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Compiling .py files...

 
0
  #8
Jun 27th, 2005
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.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Compiling .py files...

 
0
  #9
Jun 27th, 2005
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
  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
  1. python hello.py
the above method will work if you are in the same directory as the program. else do it like this
  1. python /full/path/to/hello.py
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 1
Reputation: krishnamohan516 is an unknown quantity at this point 
Solved Threads: 0
krishnamohan516 krishnamohan516 is offline Offline
Newbie Poster

Re: Compiling .py files...

 
0
  #10
Nov 18th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC