ternary operator
David LeBlanc
whisper at oz.net
Fri Feb 7 18:11:54 EST 2003
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Andrew Koenig
> Sent: Friday, February 07, 2003 14:29
> To: whisper at oz.net
> Cc: python-list at python.org
> Subject: Re: ternary operator
>
>
> David> I think you missed the point twice: it's not about indexing,
> David> it's about calling a function whose side effects you depend on
> David> (always) in a component of an expression that might not get
> David> evaluated.
>
> I didn't miss that point.
>
> I think there are two cases that are often confused with each other:
>
> 1) Calling a function with side effects that you depend on;
>
> 2) Using one expression to guard another--that is, evaluating
> one expression to determine whether another is meaningful
> before evaluating it.
>
> In general, I think that the first case makes programs harder to
> follow, and the second case makes them easier. Of course, there
> will always be exceptions, but I think this is true in general.
>
> The difference is that in case (1), the side effects happen somewhere
> else (otherwise they wouldn't be side effects), whereas in case 2,
> the parts of the computation contribute to the results of the expression
> and nothing else.
>
D'accord! (Oops, sorry, we don't like the French right now - I agree! ;) )
Dave LeBlanc
Seattle, WA USA
More information about the Python-list
mailing list