PEP 308 - suggestion for generalising the ternary operator
Oren Tirosh
oren-py-l at hishome.net
Wed Feb 12 09:31:11 EST 2003
More information about the Python-list mailing list
Wed Feb 12 09:31:11 EST 2003
- Previous message (by thread): KOBRA 2.0 - .NET for Python (now supports CALLBACKS!)
- Next message (by thread): PEP 308 - suggestion for generalising the ternary operator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Feb 12, 2003 at 02:53:42AM -0800, damien morton wrote: > One Python implimentation of the ternary operator expresses the > problem as selecting from a list of alternatives: > [tval,fval][not cond] > > I was thinking over how to generalise this into a more powerfull and > readable form and came up with this syntax: > > (cond1?value1, cond2?value2, cond3?value3, default_value) > > whose degenerate ternary operator form is: > > (cond? true_value, false_value) > > I think the parentheses should be mandatory. Hmm... If you replace ? with : the result looks surprisingly like a dictionary, with parens instead of curly braces: (cond:value, cond:value, cond:value, cond:value, default_value) Or maybe: (cond:value, cond:value, cond:value, cond:value, else:default_value) Oren
- Previous message (by thread): KOBRA 2.0 - .NET for Python (now supports CALLBACKS!)
- Next message (by thread): PEP 308 - suggestion for generalising the ternary operator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list