On Apr 29, 3:47 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote:
> 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()

jmDesktop,

With what Jerry stated,

You can see what is happening under PythonWin interactive window by
doing:
>>> dir()
before and after running chap2.py and see that FooClass is defined
without import, which gives a clue that PythonWin is not running the
script independant of the interactive window.

Or try adding the following to the end of your chap2.py:
print "Hello World"
somevar = 12345
And run in PythonWin and see what happens to your interactive window
and if somevar is defined.

If you close and open PythonWin and use the interactive window without
having first run chap2.py, you will find it behaves the same as the
mac.

Ivan
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to