[Tutor] Need help with a couple of concepts
JoanCarles p Casasín
Fri, 3 Mar 2000 21:33:09 +0100
Robin B. Lake wrote:
>Running Python on a Mac G3.
>1. Am modifying some code. There is at the bottom:
>if __name__ == '__main__':
>and after the imports:
>What is this all about?
Correct me somebody if I'm not right. But this is what I understand:
#(your filename: "TestMain.py")
print "hello world!"
if __name__ == '__main__':
This means that:
If you *run* the script you'll have "hello world" printed out.
If you *import* (import TestMain)
You won't have printed anything, but you'll be able to use any function
>2. I have some code from a Python book that requires the kjbuckets
>extension module. I've downloaded the kjbuckets module. Where in
>the Mac directory tree should I put it so that Python will find it
You can put it wherever you want, but you'be to say it to Python. Launch
the applet "EditPythonPrefs" (i'm also using a Mac ;) and write there the
path for the folder.
I personally think that a good idea is to have it in the Extensions
folder, then it should look something like:
'$(PYTHON)' is the folder where Python interpreter lives.
>3. I'm using BBEdit Lite 4.6 to edit the Python code. Any way to
>get line numbers in the source so that the Python error messages
>might be matched up better?
You've definitely move to the PythonIDE (great!) written by Just van
Rossum. You'll have lot of Python oriented features (debugger, run as
__main__ your scripts, a module browser... is C O O L !!).
If you're using Python 1.5.2 it comes with the distribution, on top. If
you've older version it's in the Contrib folder I think...
If you're using a Macintosh there's another list, Mac specific:
if you're a Python newbie don't worry, *any* question is welcome (I am
Hope this helps,