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 :P)

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

Ty in advance :P

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

You do need a way to run python however :)

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...

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.

lol, maby i should just learn C r sumthin, ive been told its too hard as a 1st language tho *-*

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.

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)

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.

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

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 hello.py

the above method will work if you are in the same directory as the program. else do it like this

python /full/path/to/hello.py

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.

./secondprogram | python firstprogram.py

You need to install the proper python IDE for your programs. You can get one at Python.org. But make sure that you type '.org', because 'python.com' is a porn site.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.