PEP 308: Pep Update
AdSR
artur_spruce at yahoo.com
Thu Feb 27 04:35:55 EST 2003
"James J. Besemer" <jb at cascade-sys.com> wrote
> > The use of ?: seems more appropriate for smaller terms,
> > and if/else for larger ones.
>
> If adopting both forms was a possibility, we'd have that luxury.
>
> Personally, I rather think that ?: fits most naturally with expressions and
> keywords fits most naturally with statements. Certainly, this reflects my
> decades of C background. But more than that, I think there's a natural
> association in that expression operators tend to be punctuation based, while
> statements virtually always are associated with keywords (all but assignment).
With C/Java background, I also prefer ?: even though it may be
cryptic. And as we often want to make a ternary fit in one line, ?:
saves us a few characters.
People without any background for ?: could get confused though, as ':'
often opens a block - it doesn't here! One option could be to use '@'
instead of ':'. It resembles 'e' a little, which could make it easier
to read (as short for 'else'). But then, '@' stands for 'at' - who
knows what other more appropriate use it may find in the future.
This leaves me with keyword options. I guess the parenthesized (if
<expr>: <expr1> else: <expr2>) is the best choice.
Cheers,
AdSR
More information about the Python-list
mailing list