approach to writing functions

Terry Reedy tjreedy at udel.edu
Tue Feb 10 09:51:38 EST 2004


"Anton Vredegoor" <anton at vredegoor.doge.nl> wrote in message
news:4028d4f4$0$3996$3a628fcd at reader1.nntp.hccnet.nl...
> "Terry Reedy" <tjreedy at udel.edu> wrote:
>
> [bart]
> >> Just asking for a bit of guidance. If my program works, should it be
> >> re-written to use functions or classes?
> >
> >Working correctly is most important.  Next is running fast enough.  Then
> >you can consider whether you or another person can read, edit, or reuse
six
> >months from now.  As for rewriting, would *you* gain some personal
benefit
> >from doing so?
>
> I disagree with the order in which you list these things, but that
> might be caused by whether one sees Python as a language to express
> ideas or as a tool to accomplish a more specific task.

I gather you are putting my list in the second category.  I see Python as
being excellent for both uses, and I think that part of its excellence is
that it works both ways as executable humancode.

The OP was asking about specific-task production code.  I believe that he
should first be praised for meeting the prime directive for such, that it
work correctly, before being critiqued for secondary stylistic goals.

> For example I
> am not a native English speaker, but I guess nobody would think it
> more important to avoid all spelling errors than to get the idea
> across.

When writing to communicate ideas to other people, 'working correctly'
means successful communication of the intended idea.  For this reason, I
sometimes post untested code that may not be exactly right but which
communicates an idea.  But when I do so, I label it as 'untested' or
'something like' to communicate that it is idea-passing code rather than
tested execution code.

 Terry J. Reedy







More information about the Python-list mailing list