[Tutor] text editors for python on mac & import

Deirdre Saoirse deirdre@deirdre.net
Sun, 24 Dec 2000 01:11:06 -0800 (PST)


On Sun, 24 Dec 2000, kevin parks wrote:

> what is the best text editor to use for python on the macintosh. I
> would love to have a python aware editor with sytax coloring, etc. Is
> there some way to turn this on in the IDLE or are mac users left
> behind once again. I looked at alpha, which is great for tcl, but it
> seems not to have a python mode.

BBEdit is the single best editor on the Mac. I don't know if the current
version does syntax highlighting for Python, but I'm hoping it will soon
if it doesn't already. At work, I use NEdit on Linux, which does (but
which I've always considered a poor cousin to BBEdit).

BBEdit has a commercial and a free (as in beer, not as in "free software")
version. It can be found at http://www.barebones.com/

I'm just glad I finally know enough about Unix to finally use all its
features. ;)

I just moved back to MacOS for my desktop OS, so I suspect I'll be going
through this again.

> I am just beginning with python and am very happy to learn it. It is
> very cool.
> 
> but i also wonder, is it not possible to use the full path for import
> as in:
> 
> import /foo/bar/mystuff *
> 
> I was unable to do this, is it no allowed?

There's two parts to this answer. Yes, it is allowed, but...you did it
incorrectly on two counts:

1) The correct procedure generally is listed on
http://www.python.org/doc/2.0b1/lib/node240.html

import sys
sys.path.insert(0, "/usr/home/joe/lib/python")
sys.path.insert(0, "/usr/local/lib/python")

In other words, you add the paths to the list of directories to search; to
do this, you must first import sys and add the paths before anything you
import that's not in an expected place.

2) On the Mac, you need to use the correct OS separator. Only MacOS X
running in native mode would use slashes; the directory separator on a Mac
is a colon. 

See: http://www.python.org/doc/2.0b1/lib/os-path.html

(I'm using MacOS X Public Beta now and I *love* it -- still a bit
unstable, but life on the edge is fun!)

-- 
_Deirdre      *      http://www.sfknit.org      *      http://www.deirdre.net
"Our society has not yet gone so far as to place blind faith in machines. In 
almost all endeavors, humans routinely correct the errors of machines."
                                                     - Florida Supreme Court