Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81804 > unrolled thread
| Started by | Roy Smith <roy@panix.com> |
|---|---|
| First post | 2014-12-02 12:18 -0500 |
| Last post | 2014-12-02 12:18 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Proposed new conditional operator: "or else" Roy Smith <roy@panix.com> - 2014-12-02 12:18 -0500
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-12-02 12:18 -0500 |
| Subject | Proposed new conditional operator: "or else" |
| Message-ID | <mailman.16495.1417541801.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
In the process of refactoring some code, I serendipitously created what I think is an essential new bit of Python syntax. The “or else” statement. I ended up with:
sites_string = args.sites or else self.config['sites']
which, of course, is a syntax error today, but it got me thinking what we could do with an “or else” construct. Perhaps an alternative to assertions? Wouldn’t it be neat to write:
foo == 42 or else
and have that be an synonym for:
assert foo == 42
:-)
Back to top | Article view | comp.lang.python
csiph-web