[Pythonmac-SIG] Re: [Tutor] sitecustomize and pythonstartup
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Fri, 1 Feb 2002 14:41:33 -0800 (PST)
On Fri, 1 Feb 2002, Christopher Smith wrote:
> OK, the question is this. The interpreter can be educated as to what
> modules are loaded (i.e. if pythonstartup imports math, you can type
> math.pi in the interpreter and be understood). Is there a way to get
> this to happen in the IDE's interpreter as well? If sitecustomize.py
> imports math I can't seem to access that at the >>> prompt.
Yes, it's possible. If we add the following fragment to our
sitecustomize.py:
###
import math
import __builtin__
__builtin__.math = math
del math
###
then the math module will magically turn on for all new interactive
sessions. Pretty convenient! *grin* At least, this works from a regular
interpreter window; I'm not quite so sure if this will work with all
IDE's.