sys.stdout

  • Thread starter =?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=
  • Start date
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Hi,

The sys.stdout stream behaves strangely in my
Python2.4 shell:
[...nothing...]

Have you ever seen sys.stdout behave like that ?
Any idea what is wrong with my Python2.4 install
or Linux (Mandrake 10.0) system ?

Cheers,

Sébastien
 
T

tiissa

Sébastien Boisgérault a écrit :
The sys.stdout stream behaves strangely in my
Python2.4 shell:
[...nothing...]

There are two things competing on your stdout: what you explicitely ask
the program to write and the prompt and echo of the interpreter.

Try this:

import sys, time
sys.stdout.write('aaa'); sys.stdout.flush(); time.sleep(2)
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Tiissa,

Thanks for your answer. The execution of your example leads to a
'aaa' display during 2 secs, before it is erased by the prompt.

This behavior is standard ? The standard output is not supposed
to *concatenate* the 'aaa' and the '>>>' ?

SB
 
R

Robert Kern

Sébastien Boisgérault said:
Tiissa,

Thanks for your answer. The execution of your example leads to a
'aaa' display during 2 secs, before it is erased by the prompt.

This behavior is standard ? The standard output is not supposed
to *concatenate* the 'aaa' and the '>>>' ?

FWIW:

Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.AAAA>>> sys.stdout.write('BBBB\n')
BBBB
--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
F

Fredrik Lundh

Sébastien Boisgérault said:
Thanks for your answer. The execution of your example leads to a
'aaa' display during 2 secs, before it is erased by the prompt.

This behavior is standard ? The standard output is not supposed
to *concatenate* the 'aaa' and the '>>>' ?

what "python shell" are you using, and what platform are you running
it on? here's what I get on a standard Unix console:
AAAA>>> sys.stdout.write("BBBB\n")
BBBBCCCC
DDDD>>>

</F>
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Robert said:
Sébastien Boisgérault said:
Tiissa,

Thanks for your answer. The execution of your example leads to a
'aaa' display during 2 secs, before it is erased by the prompt.

This behavior is standard ? The standard output is not supposed
to *concatenate* the 'aaa' and the '>>>' ?

FWIW:

Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.AAAA>>> sys.stdout.write('BBBB\n')
BBBB

Robert,

I used to have exactly this behavior on my previous platform ...
In the good old days ;)

Do you know if this behavior is mandatory ? Can I *officially*
<wink> state that my Python interpreter is broken ?

I have already tried to recompile and reinstall Python2.4
without any noticeable difference and the Python2.3 rpm
that I have tested exhibits the same behavior ... Doh !


SB
 
F

Fredrik Lundh

what "python shell" are you using, and what platform are you running
it on? here's what I get on a standard Unix console:

AAAA>>> sys.stdout.write("BBBB\n")
BBBB
CCCC
DDDD>>>

btw, what does

print ?

</F>
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Fredrik said:
what "python shell" are you using, and what platform are you running
it on?

The python interpreter is invoked from a bash/konsole session,
inside a KDE env.:

bash$ python
Python 2.4.1 (#4, Sep 8 2005, 19:11:54)
[GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
here's what I get on a standard Unix console:

AAAA>>> sys.stdout.write("BBBB\n")
BBBB
CCCC
DDDD>>>

</F>

Yep. And I hate you for this ;)

Cheers,

SB
 
J

Jorgen Grahn

The python interpreter is invoked from a bash/konsole session,
inside a KDE env.:

So, it's either of these things:
- konsole and its bugs/features
- your $TERM settings
- your readline and its bugs/features
- your ~/.inputrc settings (see the readline man page)

It's hard to say what's right and wrong really, and whose fault it is.
I'm pretty sure it's not Python. What happens if you try bash?

tuva:~> bash
grahn@tuva:~$ echo -n 'foo'
foograhn@tuva:~$

/Jorgen
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Jorgen Grahn a écrit :
So, it's either of these things:
- konsole and its bugs/features

Nothing that I could do about it ;)
- your $TERM settings

My xterm settings ?
- your readline and its bugs/features

Uh Uh ... I have disabled my $PYTHONSTARTUP script that
was using some features of the readline module, but
without any success ...
- your ~/.inputrc settings (see the readline man page)

INPUTRC refers to the default Mandrake settings in
etc/inputrc. An old version, 2002. It should be
mostly harmless said:
It's hard to say what's right and wrong really, and whose fault it is.
I'm pretty sure it's not Python. What happens if you try bash?

tuva:~> bash
grahn@tuva:~$ echo -n 'foo'
foograhn@tuva:~$

Bash (into a konsole, same conditions than befor) seems to be ok:

[boisgera@meteor boisgera]$ echo -n 'foo'
foo[boisgera@meteor boisgera]$

:(

Cheers,

SB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,315
Members
48,001
Latest member
Wesley9486

Latest Threads

Top