Using print instead of file.write(str)

John Machin sjmachin at lexicon.net
Sat Jun 3 22:52:49 EDT 2006


On 3/06/2006 9:47 AM, Bruno Desthuilliers wrote:

> 
> Now, given:
> 
>   bird = "parrot"
>   beautiful = "dead"
> 
> How would you do the following with f.write() ?
> 
>   print "this", bird, "is", beautiful
> 
> (without using string formating, of course...)

Like this:

f.write((' '.join(str(x) for x in ['this', bird, 'is', beautiful]) + '\n'))

... or was that a rhetorical question?

Cheers,
John



More information about the Python-list mailing list