On Tue, 2005-10-25 at 18:52 +0200, Noam Raphael wrote:
> On 10/24/05, guy keren <[EMAIL PROTECTED]> wrote:
> > 
> > > * Avoid non relevant command line parsing code
> >
> > i had that in order to allow running the program with different
> > parameters, without altering the code. it is true, however, that in a
> > script, "changing the code" is not something that should be feared, as
> > with compiled languages.
> >
> > i do have, however, a problem with code that requires changing in order to
> > change parameters - this is often the difference between scripts that get
> > used, and scripts that get neglected. once you realise that there's a
> > difference between the writer of the script and the user of the script -
> > you tend to favor using command-line arguments.
> >
> > in this specific case, your approach might be better.
> >
> 
 <אני מציע להשתמש בסביבת הפיתון האינטראקטיבית. כך אין צורך להתעסק עם
 <ארגומנטים לתוכנית, אלא אפשר לקרוא מיד לפונקציות. חוץ מזה, זה מאפשר
 <כשלומדים עוד דברים פשוט להוסיף פונקציות למודול (יעני, קובץ עם
 <פונקציות) שכבר קיים, ואז לא צריך לכתוב את הפונקציות שוב.
 <חוץ מזה, הסביבה האינטראקטיבית היא טובה מאוד ללימוד סתם ככה - אפשר
 <לכתוב משהו וישר לראות מה הוא עושה, ואפשר לנסות את מה שכתבנו בצורות
 <שונות מאוד בקלות.

I heartly agree with Noam.  If you want to teach them script-writing and
command-line argument parsing as an end in itself, then writing scripts
is a good idea.  But as along as your goal is writing parametrised code
focused on the topic at hand, don't write scripts at all -- write
functions!  Functions take parameters (no need to parse anything) and
return values (no need to format results).  And they are trivial to
re-use.

If you don't have enough experience with Python's interactive prompt,
you might not realise its power yet.  When experimenting with Python
code it's much more convenient than the shell.  Heavily relying on
interactive work calls all the stronger for an IDE (like IDLE).  If you
are really limited to a textual terminal, there are still some nice
environments (e.g. ipython).  I'll study the offerings and give a
reccomendation soon.  Perhaps I will even adjust the editor/prompt
keybindings to match one another.

BTW, I suggest that code examples in the reference document be written
with outputs from the interactive prompt.  E.g. don't just write::

    "hello " * 3

but write::

    >>> "hello " * 3
    'hello hello hello '

(It's also good policy to run all examples to make sure they are
correct.)

לענות