RV: RE: [Tutor] help?
Mon, 04 Feb 2002 10:27:40 -0800
At 12:04 PM 2/4/2002 +0100, Javier Jarava wrote:
>Let's see if this time, it "catches on" the list :)
I don't understand why a new user on Windows is using
DOS. IDLE is the way to go for new users on a Windows
box. I'd not recommend any tutorial which was highly
DOS-oriented to begin with -- get to that in a later
section, not right at the start.
Also, I'd focus on having new users write functions in
a module, then have them import the module in IDLE.
In other words, better to encapsulate your raw_input
loop in some def askmeloop(), than to have a lot of
code which simply executes upon importing.
I don't like .py which launch into their thing
when I simply import 'em. I consider that I'll behaved
-- I may not want to get involved in a raw_input loop
just now. I prefer that modules use the
if __name__ == "__main__": trick to treat the module
as an executable script *only if* it's kicked off at
the OS command line (or by file association, e.g. with
bang notation if the OS supports it -- Windows
In other words, my preferred intro-to-Python curriculum
would go: IDLE, Python as calculator (similar to included
tutorial), import standard modules (e.g. math), write
your own functions at the shell prompt, open text Window
in IDLE, write a few functions and save as .py file,
import .py file to use functions, mix with standard
library. After all of the above, _then_ introduce
running a script using (a) Ctrl-F5 in IDLE and (b)
going to a DOS or X-term window and going > python script.py
Then explain about sys.args and, finally, the __name__ ==
I might even do classes 'n objects (after functions),
*before* getting into the script part.