Newbie: "compiling" scrips (?)

Alan Kennedy alanmk at hotmail.com
Wed Jun 25 13:32:34 CEST 2003


Thomas Weber wrote:

> But I have some problems to execute my scripts (in Linux, bash) that I
> wrote in an editor.

It might help if you told us what you have already tried that didn't work. 

Generally, scripts are executed in one of three ways

1. Typed directly into a command line interpreter or IDE (Integrated Developed
Environment), and executed as they are typed.

2. They are created in a text editor, and executed by instructing the python
interpreter to execute them, like so

python myscriptfile.py

3. They are initiated by your *nix shell. For this to work, you need to have
what is called a "shebang line" as the first line of your script, e.g.

#myscriptfile------------------------
#!/usr/bin/python
for x in range(5):
    print "Hello world!"
#------------------------------------

and your script needs to have the execute bit set (man "chmod" for more details)

bash>myscriptfile
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!

> Is there a way to compile the scripts into binary form like
> like in C: 'gcc source.c -o binary'
> Sorry, if this was a silly question...

No, not a silly question, quite the opposite in fact. However, you'll just
confuse yourself thinking like that if you are just starting with python.

If I were you, I'd start with method 1 above, and then progress through methods
2 and 3 when you're more familiar with what's happening.

HTH,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list