[Tutor] Invoking Python

bhaaluu bhaaluu at gmail.com
Thu Jun 26 16:05:29 CEST 2008


On Thu, Jun 26, 2008 at 9:53 AM, Cédric Lucantis <omer at no-log.org> wrote:
> Le Thursday 26 June 2008 15:37:01 kinuthiA muchanE, vous avez écrit :
>> 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.
>
> This is because on unix the current directory (.) is not in the PATH
> environment variable by default. You can set it if you want but there are
> some security problems with this so it's not recommended. Typing the
> leading './' quickly becomes automatic for unix users.
>
> --
> Cédric Lucantis
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>

You can make a /home/user/bin directory and add it to your PATH by
including this line in your .bash_profile

# set PATH so it includes user's private bin if it exists
    PATH=~/bin:"${PATH}"

Place your executable Python scripts in ~/bin
Now you can execute them with the dot-slash in front of them
because they are in the PATH. BTW, the tilde (~) is equivalent to
"/home/user/".

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!


More information about the Tutor mailing list