allowing braces around suites

Isaac To iketo2 at netscape.net
Mon Aug 30 11:39:34 EDT 2004


>>>>> "Jeremy" == Jeremy Bowers <jerf at jerf.org> writes:

    Jeremy> (In Perl, "if", "for", and friends all *require* braces
    Jeremy> when used conventionally. When used as a suffix ("print $x
    Jeremy> if $iShould;"), it doesn't, but I don't find that
    Jeremy> offensive.... partially because I only rarely use it.)

Hm... then you lose one of the features that I miss most when coding
Python.  I actually use them much more often than a full if-else when
coding Perl.  In Perl, because you have your freedom to put things in
different ordering, you can easily document your program by simply
reversing the way you write.  By writing "print $x if $x_is_not_bad;"
instead of "if ($x_is_not_bad) { print $x; }" (or, "$x_is_not_bad and
print $x;" or "!$x_is_not_bad or print $x"), you document that (1) you
expect $x_is_not_bad most of the time, and (2) your main concern of
that piece of code is to print out $x rather than to check the
condition.  In Python I got no such freedom.  Anyways, Python is not
designed to be that implicit.

Regards,
Isaac.



More information about the Python-list mailing list