Thanks, Steven. :-) I'll get back to this this evening. Lisi On Saturday 20 August 2011 16:51:07 Steven D'Aprano wrote: > Lisi wrote: > > I have got myself well and truly bogged down. I need to change the angle > > from which I am looking. I only have a short while left for now in which > > to make some sort of progress with Python. What do people think of: > > > > http://www.sthurlow.com/python/ > > > > Is it reasonably accurate and therefore useful? > > As far as I can tell after a lightning fast read of it (about three > minutes to skim a few of the lessons), it seems perfectly fine to me. > > [...] > > > To show you what I mean: > > How to save and run a bash script: > > Write your script > > save it in the normal manner > > chmod to x for everyone you want to be able to execute it. (E.g. where > > owner is root: perhaps 744) > > Either move the file into a directory on your path, or add the directory > > that the file is in to your path. > > It will now run. > > > > Can anyone point me to a similar set of basic instructions for Python > > modules?? > > More or less exactly the same, except you need a hash-bang line at the > top of the script so that the shell knows that it is Python and not a > shell script. So you can add a line like: > > #!/usr/bin/python > > at the VERY TOP of your script (it MUST be in the first line for the > shell to recognise it). > > (This is exactly the same practice for all scripting languages, > including Perl, Bash, Ruby, and many more... if the hash-bang line is > missing, the shell will try to execute the file with "sh".) > > > As an alternative, you can call the script from the shell prompt like this: > > > $ python path/to/my/script.py > > (naturally you don't type the $ that is just the shell prompt) > > > Finally, you can put your script somewhere in the PYTHONPATH and then > call it like this: > > > $ python -m script > > > Note that this way you leave the .py off the end -- you're not telling > Python to *run* a file, but to *import* a file, which happens to run it > as a side-effect. I don't recommend you use this technique until you're > more comfortable with Python. I mention it only for completeness.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor