Thread: [Boa Constr] Newbie shell question
Status: Beta
Brought to you by:
riaan
From: Raaijmakers, V. (I. GE Interlogix) <Vin...@ge...> - 2003-08-29 01:56:17
|
Inspired by all the IDE mail of this week in the python user group I = started to use Python in order to experience if this is the IDE I'm = looking for. Everything works fine, it looks really hopeful, which is an = understatement. =20 In this learning phase, there is one thing I can't figure out. I would love that the interpreter/shell starts in the path of my = workspace.=20 Well, I can't even find a workspace preference. Is there any?The place = where all the modules under construction are located. So when the interpreter/shell starts, I'm able to import directly the = modules and classes from that workspace. =20 How to do that without all kind of sys.path.append("<workspace path>") = tricks? =20 Vincent=20 |
From: Riaan B. <riaan@e.co.za> - 2003-08-29 10:46:16
|
Hi Vincent, Raaijmakers, Vincent (IndSys, GE Interlogix) wrote: > Inspired by all the IDE mail of this week in the python user group I > started to use Python in order to experience if this is the IDE I'm > looking for. > Everything works fine, it looks really hopeful, which is an understatement. > > In this learning phase, there is one thing I can't figure out. > I would love that the interpreter/shell starts in the path of my workspace. Boa tries to emulate a standard Python shell. There is no real concept of the Shell "starting" anywhere. Only sys.path is used. What you refer to is the '' (== os.getcwd() ) entry on sys.path. To fix problems with late imports (where the process' cwd had changed), I changed the '' sys.path entry to be an absolute path (Python 2.3 now also does this when running scripts :). Unfortunately this prevents shell from being able to import from the cwd. (Python 2.3 leaves the '' entry when run as a shell) The fix for Boa would be to both have the '' and the absolute version on sys.path. > Well, I can't even find a workspace preference. The preference that controls the process' cwd is: Preferences->General->Explorer->exWorkingDirectory This setting is the one you're looking for, and will work if '' is in sys.path. > Is there any?The place > where all the modules under construction are located. > So when the interpreter/shell starts, I'm able to import directly the > modules and classes from that workspace. exWorkingDirectory is a start. It might be an idea to automatically add the directory of Application type files open in the Editor to sys.path. You can explicitly do this indirectly via File->Import module into Shell from a module. Maybe linking Bookmark directories to sys.path is also a possibility. (Bookmarks used to be called Workspace ages ago ;) > How to do that without all kind of sys.path.append("<workspace path>") > tricks? Currently that's the only workaround ;) You can do: >>> sys.path.insert(0, '') in the shell. Or you can add that line to your PYTHONSTARTUP file. Or you can create a plug-in file in the Plug-ins dir called SysPathFix.plug-in.py containing this line: import sys; sys.path.insert(0, '') Cheers, Riaan. |