For review: PEP 308 - If-then-else expression
Ian Sparks
Ian.Sparks at etrials.com
Fri Feb 7 14:33:19 EST 2003
>>
iff(<condition>, <trueresult>, falseresult) which returns <trueresult> if <condition> is true,
otherwise returns <falseresult
<<
MSAccess Basic had this exact construct which they called an "Inline IF".
Only difference is that it was "iif" instead of "iff"
- Ian Sparks.
-----Original Message-----
From: Harvey Thomas [mailto:hst at empolis.co.uk]
Sent: Friday, February 07, 2003 2:05 PM
To: Jack Diederich; python-list at python.org
Subject: RE: For review: PEP 308 - If-then-else expression
Jack Diederich wrote:
> Sent: 07 February 2003 18:18
> To: python-list at python.org
> Subject: Re: For review: PEP 308 - If-then-else expression
>
>
> On Fri, Feb 07, 2003 at 06:46:55PM +0100, holger krekel wrote:
> > What about a missing else clause? e.g.
> >
> > <expression> if <condition>
>
> if (<condition>): <expression>
>
> is already legal so I'm -1 for yet another way to do it
>
> > Allowing it could be nice for stuff like
> > result = obj(...) if callable(obj)
>
> -1 as above
>
> > Note though, that this proposal obfuscates control "flow"
> > (which guido already knows, of course). You can't read it
> > neither from "left to right" nor from "right to left".
>
> a good reason for -1, another would be that perl has both
> ways of doing it ;)
>
Agree with your comments.
What about a built-in function?
iff(<condition>, <trueresult>, falseresult) which returns <trueresult> if <condition> is true,
otherwise returns <falseresult
The flow is left to right (more or less), it's similar to constructs in other languages.
It can of course be written in Python currently in a rather horrible way.
Harvey
_____________________________________________________________________
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list