[Tutor] Invoking Python

bhaaluu bhaaluu at gmail.com
Thu Jun 26 15:57:41 CEST 2008


You can create a Python script on a *nix system and run it with:

$ python threeplusfour.py

You can place a shebang line as the first line of the script, which points
to the python interpreter:

#!/usr/bin/python
print("Hello, world!\n")

Save the file, then make it an executable with:

$ chmod u+x threeplusfour.py

Then execute it with:

$ ./threeplusfour.py

Why the dot-slash? Here is a good explanation:
http://www.linfo.org/dot_slash.html

You can also create a Python script and place it in a directory that is
included in your PATH (echo $PATH). Once the executable script is in
a directory in your PATH, you can execute it with:

$ threeplusfour.py

Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
Kid on Bus: What are you gonna do today, Napoleon?
Napoleon Dynamite: Whatever I feel like I wanna do. Gosh!

On Thu, Jun 26, 2008 at 9:37 AM, kinuthiA muchanE <muchanek at gmail.com> wrote:
>
> On Thu, 2008-06-26 at 12:00 +0200, tutor-request at python.org wrote:
>> Or more commonly add a first line like:
>>
>> #! /path/to/python/executable
>>
>> Then you can simply make the file executable and run it by typing its
>> name
>>
>> $ threeplusfour.py
>
> On my computer, running Linux Ubuntu, I always have to type
> ./threePlusFour.py to get it to run. Otherwise I get a not found
> command.
>>
>> or double clicking it in your favourite file manager GUI tool.
>>
>> See the topic "Add a Little style" in my tutorial,  in the box
>> Note for Unix users
>> for more details.
>>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list