Again: Please hear my plea: print without softspace

Stephen Horne steve at ninereeds.fsnet.co.uk
Thu Mar 4 17:05:22 EST 2004


On Thu, 04 Mar 2004 22:12:14 +0100, Peter Maas
<fpetermaas at netscape.net> wrote:

>Martin Bless schrieb:
>> And then: Is it possible to reopen sys.stdout if the platform ist not
>> Unix-like?
>
>Yes but e.g. Win32 does not know /dev files, so am not sure what
>to substitute for /dev/tty. DOS had a "device" called CON which is
>still alive in Win32 consoles (echo Hi > CON) but I have not tested
>that.
>
>Mit freundlichen Gruessen,
>
>Peter Maas

Easy solution - write your extender such that it takes the original
file in the constructor...

  sys.stdout = ExtendedFile (sys.stdout)


One thing, though - can't this cause problems when different modules
separately import 'sys'. Given that the new sys.stdout should be
compatible with the old one (use inheritance and just add/override the
required methods) I'm far from sure, but this approach makes me feel a
bit uneasy - I suspect a future of obscure and hard to trace bugs.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk



More information about the Python-list mailing list