Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99292
| From | George Trojan <george.trojan@noaa.gov> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | tuples in conditional assignment |
| Date | 2015-11-24 03:25 +0000 |
| Message-ID | <mailman.83.1448335555.2291.python-list@python.org> (permalink) |
| References | <mailman.36.1447434002.19880.python-list@python.org> |
The following code has bitten me recently: >>> t=(0,1) >>> x,y=t if t else 8, 9 >>> print(x, y) (0, 1) 9 I was assuming that a comma has the highest order of evaluation, that is the expression 8, 9 should make a tuple. Why this is not the case? George
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
tuples in conditional assignment George Trojan <george.trojan@noaa.gov> - 2015-11-24 03:25 +0000 Re: tuples in conditional assignment Steven D'Aprano <steve@pearwood.info> - 2015-11-24 22:25 +1100
csiph-web