PEP308: Yet another syntax proposal

Raymond Hettinger vze4rx4y at verizon.net
Mon Feb 10 10:52:24 EST 2003


I suggest:

    cond  ??  val1  ||  val2

* Having two characters at each step helps visually segregate the
components.
* The ?? and || strongly suggest testing and alternation.
* Doesn't overload or confuse with existing operators.
* No new keywords.
* In-order presentation.
* Short and easy to read.


Using Martin Maney's live code examples, here's what it looks like:
    i = j>=0 ?? j || n
    sy = d0.year - (d0.month<7  ??  1  ||  0)
    add2url = '?' + (params.has_key('add2url')  ??  params['add2url']  ||
'')
    tail = (len(events)>1 ??  ' '  ||  '<br>') + tail


Raymond Hettinger






More information about the Python-list mailing list