A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033147.html below:

[Python-Dev] Re: Trinary Operators

[Python-Dev] Re: Trinary Operators [Python-Dev] Re: Trinary OperatorsChad 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)





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4