Re: sys.stdout and Python3

2013-11-24 Thread Chris Angelico
On Mon, Nov 25, 2013 at 1:31 AM, Steven D'Aprano wrote: > I don't think the REPL handles return values inside loops any different > from how it handles them outside loops. The difference is that file.write > methods used to return None in Python 2, in Python 3 they return the > number of bytes wri

Re: sys.stdout and Python3

2013-11-24 Thread Steven D'Aprano
On Sun, 24 Nov 2013 01:16:18 +1100, Chris Angelico wrote: > On Sun, Nov 24, 2013 at 12:26 AM, Frank Millman > wrote: >> for i in range(10): >> sys.stdout.write('.') >> sys.stdout.flush() >> time.sleep(1) >> sys.stdout.write('\n') >> >> I tried it under Python3, and found that it differs in

Re: sys.stdout and Python3

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 12:26 AM, Frank Millman wrote: > for i in range(10): > sys.stdout.write('.') > sys.stdout.flush() > time.sleep(1) > sys.stdout.write('\n') > > I tried it under Python3, and found that it differs in two ways - > > 1. Each 'write' is terminated by a newline > 2. Each 'w

Re: sys.stdout vs. sys.stderr

2010-03-09 Thread Mitchell L Model
On Jan 11, 2010, at 1:47 PM Nobody wrote: On Mon, 11 Jan 2010 10:09:36 +0100, Martin v. Loewis wrote: In Python 3.1 is there any difference in the buffering behavior of the initial sys.stdout and sys.stderr streams? No. Were they different at some earlier point in Python's evolution?

Re: sys.stdout vs. sys.stderr

2010-01-11 Thread Nobody
On Mon, 11 Jan 2010 10:09:36 +0100, Martin v. Loewis wrote: >> In Python 3.1 is there any difference in the buffering behavior of the >> initial sys.stdout and sys.stderr streams? > > No. > >> Were they different at some earlier point in Python's evolution? > > That depends on the operating sys

Re: sys.stdout vs. sys.stderr

2010-01-11 Thread Martin v. Loewis
> In Python 3.1 is there any difference in the buffering behavior of the > initial sys.stdout and sys.stderr streams? No. > Were they different at some earlier point in Python's evolution? That depends on the operating system. These used to be whatever the C library set up as stdout and stderr.

Re: sys.stdout is not flushed

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 23:08:25 +0100, Diez B. Roggisch wrote: > Try printing > >stdout.write('\r-->%d') ^M-->0^M-->1^M-->2^M-->3... ;) But it's probably good enough for the OP's purposes. -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 8:54 pm, Dave Angel wrote: > Jankins wrote: > > On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > > >> Jankins schrieb: > > >>> I am trying to use sys.stdout to print out "process-bar" like: > >>> -->1% > > >>> Here is my program ‘test.py’: > > >>> from sys import stdout > >>> for v in r

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 8:32 pm, Cousin Stanley wrote: > >> > >> You misunderstand what "flush" means. It is not about > >> clearing the screen, or the line. > > >> Try printing > > >>    stdout.write('\r-->%d') > > >> Diez > > > But there is still a problem. When you use control character '\r', > > you a

Re: sys.stdout is not flushed

2009-11-23 Thread Dave Angel
Jankins wrote: On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: Jankins schrieb: I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flu

Re: sys.stdout is not flushed

2009-11-23 Thread Cousin Stanley
>> >> You misunderstand what "flush" means. It is not about >> clearing the screen, or the line. >> >> Try printing >> >>    stdout.write('\r-->%d') >> >> Diez > > > But there is still a problem. When you use control character '\r', > you actually move to the head of the current buffer line

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > Jankins schrieb: > > > > > > > I am trying to use sys.stdout to print out "process-bar" like: > > -->1% > > > Here is my program ‘test.py’: > > > from sys import stdout > > for v in range(10): > >     stdout.write('-->%d' % v) > >     stdout.flush()

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > Jankins schrieb: > > > > > > > I am trying to use sys.stdout to print out "process-bar" like: > > -->1% > > > Here is my program ‘test.py’: > > > from sys import stdout > > for v in range(10): > >     stdout.write('-->%d' % v) > >     stdout.flush()

Re: sys.stdout is not flushed

2009-11-23 Thread Diez B. Roggisch
Jankins schrieb: I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flush() else: stdout.write('done!') #end for Then, I use 'python -u test.py' to run this s

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Thierry
> Are you sure that Python wasn't just printing out "\n" because you'd > asked it to show you the repr() of a string containing newlines? Yes, I am sure. Because I dumped the ord() values to check them. But again, I'm stumped on how complicated I have made this. I should not try to code anymore at

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Steve Holden
Thierry wrote: > Thank you to both of you (Marc and Tino). > > I feel a bit stupid right now, because as both of you said, encoding > my source string to utf-8 do not produce an exception when I pass it > to urllib.quote() and is what it should be. > I was certain that this created an error sooner

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Thierry
Thank you to both of you (Marc and Tino). I feel a bit stupid right now, because as both of you said, encoding my source string to utf-8 do not produce an exception when I pass it to urllib.quote() and is what it should be. I was certain that this created an error sooner, and id not tried it again

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Nov 2008 12:18:26 -0800, Thierry wrote: > I have realized an wxPython simple application, that takes the input of > a user, send it to a web service, and get back translations in several > languages. > The service itself is fully UTF-8. > > The "source" string is first encoded to "lati

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-11 Thread Tino Wildenhain
Thierry wrote: Hello fellow pythonists, I'm a relatively new python developer, and I try to adjust my understanding about "how things works" to python, but I have hit a block, that I cannot understand. I needed to output unicode datas back from a web service, and could not get back unicode/multi

Re: sys.stdout assign to- bug

2008-03-13 Thread castironpi
> import sys > class ThreadedOut: >         def __init__( self, old ): >                 self._old= old >         def write( self, s ): >                 self._old.write( s ) > sys.stdout= ThreadedOut( sys.stdout ) > > Python 3.0a2 WinXP, on the console.  'a' is undeclared but error > message isn't

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Jorgen Grahn a écrit : > On 9 Sep 2005 03:40:58 -0700, Sébastien Boisgérault <[EMAIL PROTECTED]> wrote: > > > > Fredrik Lundh wrote: > >> Sébastien Boisgérault wrote: > >> > >> > Thanks for your answer. The execution of your example leads to a > >> > 'aaa' display during 2 secs, before it is era

Re: sys.stdout

2005-09-09 Thread Jorgen Grahn
On 9 Sep 2005 03:40:58 -0700, Sébastien Boisgérault <[EMAIL PROTECTED]> wrote: > > Fredrik Lundh wrote: >> Sébastien Boisgérault wrote: >> >> > 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 behav

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Fredrik Lundh a écrit : > > what "python shell" are you using, and what platform are you running > > it on? here's what I get on a standard Unix console: > > > import sys > sys.stdout.write("") > > >>> sys.stdout.write("\n") > > > sys.stdout.write("\n") >

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Fredrik Lundh wrote: > Sébastien Boisgérault wrote: > > > 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

Re: sys.stdout

2005-09-09 Thread 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: > import sys sys.stdout.write("") > >>> sys.stdout.write("\n") > sys.stdout.write("\n") > > >>> btw, what does >>> sy

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Robert Kern wrote: > Sébastien Boisgérault wrote: > > 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* t

Re: sys.stdout

2005-09-09 Thread Fredrik Lundh
Sébastien Boisgérault wrote: > 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" a

Re: sys.stdout

2005-09-09 Thread Robert Kern
Sébastien Boisgérault wrote: > 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: P

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
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 -- http://mail.python.org/mailman/listinfo/pyt

Re: sys.stdout

2005-09-09 Thread tiissa
Sébastien Boisgérault a écrit : > The sys.stdout stream behaves strangely in my > Python2.4 shell: > > >>> import sys > >>> sys.stdout.write("") > >>> sys.stdout.write("\n") > > >>> sys.stdout.write("\n") > > >>> sys.stdout.flush() > [...not

Re: sys.stdout question

2005-05-02 Thread Peter Otten
chris patton wrote: > I tried adding the comma at the end > print 'hello', > It still added that extra character. http://mail.python.org/pipermail/python-list/2003-September/184181.html Peter -- In diesen Kreisen kreiselt sich der Kreisler -- http://mail.python.org/mailman/listinfo/python-li

Re: sys.stdout question

2005-05-02 Thread M.E.Farmer
Save your script and run that from a commandline or import it with your python shell. ['this is a string.', ' ', 'This is another string.'] You are seeing a side effect of the interactive shell. ['this is a string.', '\n', 'This is another string.','\n'] It would be hard to get to the next prompt

Re: sys.stdout question

2005-05-02 Thread chris patton
I tried adding the comma at the end print 'hello', It still added that extra character. -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout question

2005-05-01 Thread M.E.Farmer
Print is the culprit here. Note item 2. >>> help('print') 6.6 The print statement print_stmt::="print" ( [expression[1] ("," expression[2])* [","]] | ">>" expression[3] [("," expression[4])+ [","]] ) Download entire grammar as text.[5] print e

Re: sys.stdout question

2005-05-01 Thread Steve Holden
chris patton wrote: import sys class stuff: > > ... things = [] > ... def write(self, string): > ... self.things.append(string) > ... > def_stdout = sys.stdout sys.stdout = stuff() print 'this is a string.' print 'This is another string.' sys.