A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2001-January/011916.html below:

[Python-Dev] Stupid Python Tricks, Volume 38 Number 1

[Python-Dev] Stupid Python Tricks, Volume 38 Number 1 [Python-Dev] Stupid Python Tricks, Volume 38 Number 1Guido van Rossum guido@digicool.com
Sat, 20 Jan 2001 11:43:49 -0500
> I had a huge string and wanted to put a double-quote on each end.  The
> boring:
> 
>     '"' + huge + '"'
> 
> does the job, but is inefficent <snort>.  Then this transparent variation
> sprang unbidden from my hoary brow:
> 
>     huge.join('""')

Points off for obscurity though!  My favorite for this is:

    '"%s"' % huge

Worth a microbenchmark?

> *That* should put to rest the argument over whether .join() is more properly
> a method of the separator or the sequence -- '""'.join(huge) instead would
> look plain silly <wink>.
> 
> not-entirely-sure-i'm-channeling-on-this-one-ly y'rs  - tim

Give up the channeling for a while -- there's too much interference in
the air from the Microsoft threaded stdio debate still. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)



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