".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Thu Dec 16 11:30:16 CET 2004

Nick Coghlan schrieb:
>>>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
>>>>> result = []
>>>>> for d in data:
> .>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
> .>>> from itertools import chain
> .>>> result = "".join(chain(*data))
> 'foobarbazmyyourholygrail'

This is the first time I see that and I totally like the idea of writing 
".>>>" instead of ">>>" at the beginning of a line. Thank you Dr. Dobb! 
It's unfortunate for c.l.py that Python uses ">>>" as the default prompt 
as it messes up the display on mail/news readers that provide "syntax 
highlighting" for quotes.

I wish everyone would write examples that way! On the other hand - three 
levels of quoting are really rare, maybe it would be easier to change that 
in the mail readers...

... or in Py3k ?


More information about the Python-list mailing list