Python executable

2005-09-05 Thread presentt
Hello,

I'm running Ubuntu Linux 5.04.

I just started teaching myself Python today, and have been reading a
few things to get started.  I came across something in one (namely
http://docs.python.org/tut/node4.html#SECTION00422)
that confused me a little.

It says:



On BSD'ish Unix systems, Python scripts can be made directly
executable, like shell scripts, by putting the line

#! /usr/bin/env python

(assuming that the interpreter is on the user's PATH) at the beginning
of the script and giving the file an executable mode. The "#!" must be
the first two characters of the file. On some platforms, this first
line must end with a Unix-style line ending ("\n"), not a Mac OS ("\r")
or Windows ("\r\n") line ending. Note that the hash, or pound,
character, "#", is used to start a comment in Python.

The script can be given a executable mode, or permission, using the
chmod command:

$ chmod +x myscript.py

---

So I created a file named helloworld.py, and put in it:

#! /usr/bin/env python
print "Hello, world!"

and then used
$ chmod +x helloworld.py
to set the permissions.  Finally, I went to my terminal and typed
$ helloworld.py
but I was given the bash: helloworld.py: command not found error.

Can someone tell me
(1)Am I right in saying that something is directly executable if I can
enter the filename in the command line and it runs?
(2)Am I setting up the script to be directly executable correctly?
and (3)Am I trying to run the directly executable script correctly?

Thanks a lot.  I hope this post isn't too hard to follow; I know I'm
asking a lot.

~~Ted Present

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python executable

2005-09-06 Thread presentt
Thanks everyone!  I think I'm going to stick with Python; at least I
know there are some people here willing to help.

-- 
http://mail.python.org/mailman/listinfo/python-list


~ after script filename?

2005-09-06 Thread presentt
Hello all,

I just wrote a really simple script and named it helloworld.py.  Inside
was only:

#!/usr/bin/env
print "Hello, world"

I used chmod to set the permissions, and ran it to see what happened (I
just started learning Python, if you couldn't guess)

Then, I typed ls in the directory to see what was there, and I noticed
a new file, namely helloworld.py~ .  What is that file (its contents
are identicle to helloworld.py)?  Why the ~?

Thanks a lot.  I'm using Ubuntu Linux 5.04 (Hoary), and wrote the
script with gedit.

~~Ted Present

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ~ after script filename?

2005-09-06 Thread presentt
Huh, no ~ on other files when I edit them, but at least I don't have to
worry about it.  Thanks Aldo.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ~ after script filename?

2005-09-07 Thread presentt
Oh okay.  Thank you all.

Now that you mention it, the ~ makes sense; I know M$ Word uses a ~ in
the temp files that it autosaves periodically.  And I think I've seen
it with M$ Notepad too.

Thanks again.

-- 
http://mail.python.org/mailman/listinfo/python-list


Event on executable launch

2005-09-14 Thread presentt
Hello,

Is there a way to make my Python program do something whenever any
executable is launched in Linux?  Like, for instance, a class that
represents the operating system or something?

Thanks a bunch.

~~Ted Present

-- 
http://mail.python.org/mailman/listinfo/python-list