Python from Wise Guy's Viewpoint

Hannu Kankaanp?? hanzspam at yahoo.com.au
Mon Oct 20 12:47:43 EDT 2003


Alex Martelli <aleax at aleax.it> wrote in message news:<OwOkb.19485$e5.710958 at news1.tin.it>...
> Yes -- which is exactly why many non-programmers would prefer the
> parentheses-less notation -- with more obvious names of course;-).
> E.g.:
> emitwarning URGENT "meltdown imminent!!!"
> DOES look nicer to non-programmers than
> emitwarning(URGENT, "meltdown imminent!!!")

It depends on the background of the non-programmer. I'd
say most non-programmers who turn into programmers have at
least some math experience, so they won't be scared to type
1 + 2 instead of "give me the answer to one plus two, thank you".
The latter group we can always guide to COBOL ;) (if my
understanding of that language is correct). And the former
group should be familiar with the function notation.

Perhaps, despite of Guido's urge for "programming for everyone",
Python has been designed with such a group in mind that has at
least some hope of becoming programmers ;)

> > You really don't get any of this "explicit is better than implicit"
> > thing, do you? Requiring people to write "return" instead of
> > leaving it as optional like in Ruby, is again one reason why
> > Pythonistas *like* Python instead of Ruby. You come to
>
> I think that making return optional is slightly error-prone,
> but it DOES make the language easier to learn for newbies --
> newbies often err, in Python, by writing such code as
>     def double(x): x+x
> which indicates the lack of 'return' IS more natural than its
> mandatory presence.

You're right. That definition of double is closer to what
programming newbies probably have learned in math, than one
with "return". But that's not the point I was arguing really.
It was that Pythonistas prefer the explicit "return" and don't
want it to be changed -- So it's silly to present it as one of
Python's flaws.

Well ok, that was a pretty bold claim with no extensive
studies to back it up, and even contradicts my previously
expressed need to be compatible with math. So sure, it's 
a tradeoff, but unlike the 'no-parens'-syntax, explicit
return adds to code readability without affecting the basic
notation as comprehensively as the lack of parens in
function calls (such as making higher-order functions less
intuitive to use).

Actually my preference is to either always require return when
there's something to return, or never allow return. Making it
optional just leads to less uniformity. And disallowing it
entirely in an imperative language wouldn't be such a wise
move either.




More information about the Python-list mailing list