For review: PEP 308 - If-then-else expression
Michele Simionato
mis6 at pitt.edu
Sat Feb 8 18:51:08 EST 2003
More information about the Python-list mailing list
Sat Feb 8 18:51:08 EST 2003
- Previous message (by thread): For review: PEP 308 - If-then-else expression
- Next message (by thread): For review: PEP 308 - If-then-else expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Sean Ross" <sross at connectmail.carleton.ca> wrote in message news:<mid1a.6921$Zt4.1230197 at news20.bellglobal.com>... > From updated PEP308: > > > Another variant proposes to use 'when' instead of 'if': > > > > <expression1> when <condition> else <expression2> > > > > I don't see the advantage of 'when' over 'if'; it adds a new > > keyword which is a major extra hurdle to introduce this. I think > > that using a different keyword suggests that the semantics are > > different than those of an 'if' statement; but they really aren't > > (only the syntax is different). > > It would appear that adding a new keyword is a problem: "major extra > hurdle", to be precise. There _really_ aren't any semantic differences, per > se. I just thought it would help distinguish between if expressions and if > statements and it would eliminate the possibility of > if x if C else y: > pass > But, it looks like x if C else y will cause fewer problems to > implement, and besides its not that difficult to tell the difference between > if C: > x > else: > y > and > x if C else y > > And, as someone posted, you can always use > if (x if C else y): > pass > > So, I think I'll just give the 'when' advocacy a rest... > (I do still prefer it, though... ;D ) > I think somebody pointed out that x when C else y could be implemented without making "when" a reserved keyword and I would prefer "when" to "if". M.
- Previous message (by thread): For review: PEP 308 - If-then-else expression
- Next message (by thread): For review: PEP 308 - If-then-else expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list