[Tutor] if ... else shorthand form ?
dave selby
dave6502 at googlemail.com
Sat Feb 9 10:21:41 CET 2008
Hi all,
Returning to python after a brief affair with C++, I have the following code ...
if (items.has_keys('snapshot_interval')):
self.snap_init[i] = items['snapshot_interval']
else:
self.snap_init[i] = 0
I thought Python had a shorthand version of something like ....
self.snap_init[i] =
(items.has_keys('snapshot_interval'))?items['snapshot_interval']:0
Googled but no luck ... or is it my poor overloaded brain getting confused ?
Cheers
Dave
--
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
More information about the Tutor
mailing list