[Python-Dev] Re: Trinary Operators
Chad Netzer
cnetzer@mail.arc.nasa.gov
06 Feb 2003 18:01:14 -0800
On Thu, 2003-02-06 at 17:38, Ka-Ping Yee wrote:
> For example, here's a common idiom i use in C:
>
> printf("Read %d file%s.", count, count == 1 ? "" : "s");
Just for giggles, here is a python version:
print "Read %d file%s." % (count, {1:""}.get(count,"s"))
Exact same number of characters, even. :)
--
Bay Area Python Interest Group - http://www.baypiggies.net/
Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)