Simple import question about mac osx

Jerry Hill malaclypse2 at gmail.com
Tue Apr 29 22:47:10 CEST 2008


On Tue, Apr 29, 2008 at 3:17 PM, jmDesktop <needin4mation at gmail.com> wrote:
>  On Windows I took the text file I created on mac with vi and opened it
>  in PythonWin.  I ran it.  It compiled.  I run the import and call from
>  the python interpreter.

You're not doing what you think you're doing.  I'm not sure I know the
right way to explain it, though.

When you run your code in pythonwin, it's just like calling 'python -i
chap2.py'  It runs the code in chap2.py, then gives you an interpreter
window to interact with your code.  In this case, that means that
FooClass is visible with no import at all, because it was defined in
the scope of the currently running script, as opposed to being
imported.

You haven't said exactly how you're doing this on your mac, but I'm
guessing that you're opening a command line, starting up the python
interpreter, then going from there?

Can someone help me out?  I'm running into a mental block on how to
explain the difference between doing this:
C:\Python25>python -i chap2.py
>>> foo1=FooClass()
Created a class instance for  John Doe
>>>

and doing this:
C:\Python25>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import chap2
>>> foo1=chap2.FooClass()
Created a class instance for  John Doe
>>>

-- 
Jerry



More information about the Python-list mailing list