> 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