Dumb python questions

Bruce Sass bsass at freenet.edmonton.ab.ca
Thu Aug 16 04:41:30 EDT 2001


On 15 Aug 2001, Paul Rubin wrote:
<...>
> Yes, but if you have to resort to such tricks as sys.stdout.write, it
> makes Python less pleasant to program in.  Is there a way to get rid
> of the extra space with the string formatting operator?

Is this the kind of thing you are after...

>>> prints = sys.stdout.write
>>> str = 'abc'
>>> for i in ['a', 'b', ' ', 'c', str, '\n']:
...     prints(i)
...
ab cabc
>>>

...rather than...

>>> for i in ['a', 'b', ' ', 'c', str, '\n']:
...     print i,
...
a b   c abc
>>>

I guess I just don't see sys.stdout as a trick, print is the trick
because it wraps sys.stdout.write up with some formatting shortcuts.


- Bruce





More information about the Python-list mailing list