Simple Question regarding running .py program

Dave Angel d at davea.name
Tue Nov 13 10:25:42 CET 2012


On 11/12/2012 09:45 PM, Caroline Hou wrote:
<snip all the doublespaced quotes>
> 
> Hi Dave!
> 
> thank you very much for your quick reply! I did manage to get the program run from cmd.exe. 
> So does it mean that if I want to use python interactively,I should use the interpreter,while if I just want to run a python program, I should use DOS shell instead?

The DOS shell is one answer that settled both of your original
questions.  It's also how I run about 90% of the time.  But different
people have different preferences.

The interpreter is great for experimenting.  But if you have non-trivial
code (presumably written in a file), then you have to import it.  Which
means references to the stuff there are done with mymodule.myfunction.
That can get tiresome after a while.  And if you have to change the
source file, it's not always safe to reload it (so I never do).  If I've
imported something, and that something has changed, I quit the
interpreter and start it over.

When you're running the script as a whole from the DOS box, it's always
a clean start.

> Also, how could I edit my script? I have sth called "IDLE" installed along with python. Is it the right place to write/edit my script?

Any text editor will do, but especially one with some knowledge of the
Python syntax.  Don't use Notepad.  I've never used IDLE (I use a
commercial one called Komodo IDE), so I can't say how good it is.  Many
people love IDLE, though.

The thing is, any IDE will require some setup (setting directory paths,
project settings, etc.), and some getting used to.  Some don't work very
well for GUI programs, others truncate traceback listings (maybe giving
you a GUI view of the same information).  Some apparently won't even let
you copy/paste a traceback into a mail message.  So it's very useful to
also get thoroughly acquainted with the cmd prompt.

> Sorry about these semi-idiot questions but it is really hard to find an article or book that covers such basic stuffs! 

Nothing wrong with those questions.  Welcome to Python-list.

-- 

DaveA


More information about the Python-list mailing list