<div class="gmail_quote">I see that Python 3 behavior is consistent on Windows too meaning it doesn't output anything on the screen when end=''</div><div class="gmail_quote"><br></div><div class="gmail_quote">It seems that basic function print() that was created to just "print a string" got over-engineered breaking unix principle of "doing one thing". It reminds me of subprocess.Popen which was also designed to just "run a process". I would keep it as simple as possible for printing stuff to the screen without any implicit buffering. You called print() - you get the output. KISS. If people need more control with output buffering - provide a pointer to sys.stdout with all gory details about streams etc.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">To get back on topic, let me give a definition. To me "pythonic" means "intuitive" in the first place. And "intuitive" means "up to user expectations". What does user expect from "print()" function? Writing to a file? I don't think so. Output to printer? Maybe. Printing to the screen? Definitely.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">"intuitive" also means that users won't have to consult user documentation for every basic thing it needs, especially for such basic thing such as getting some stuff printed to the screen output - the stuff that is essential in the coding process. It is already less convenient in Py3k, because you need to type extra Shift-9 and Shift-0 in the process, and it risks to become completely weird:</div>
<div class="gmail_quote"><br></div><div class="gmail_quote"> print('calling external process... ', end='')</div><div class="gmail_quote"> sys.output.flush()</div><div class="gmail_quote"> ...</div><div class="gmail_quote">
print('done')</div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">So, py3k print() is not pythonic. To make it pythonic, the output should be immediately available after you call it. If you need to buffer output - do this explicitly, because print() doesn't guarantee that it will be buffered anyway. If you care about performance - use sys.stdout directly and tune it explicitly.</div>
<div class="gmail_quote"><br></div>
<div class="gmail_quote"><br></div><div class="gmail_quote">On Mon, Jan 9, 2012 at 4:25 PM, Devin Jeanpierre <span dir="ltr"><<a href="mailto:jeanpierreda@gmail.com" target="_blank">jeanpierreda@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>> This produces one dot every second with Python 2.7.2 on Windows.<br>
<br>
</div>Weird. Must be a windows thing.<br>
<div><br>
> I assume you use Linux. Do you agree that for cross-platform language some<br>
> behavior should be made consistent?<br>
<br>
</div>Yes. I guess that's why they changed the behavior of print on Windows<br>
in Python 3.<br>
<span><font color="#888888"><br>
-- Devin<br>
</font></span><div><div><br>
On Mon, Jan 9, 2012 at 7:21 AM, anatoly techtonik <<a href="mailto:techtonik@gmail.com" target="_blank">techtonik@gmail.com</a>> wrote:<br>
> On Mon, Jan 9, 2012 at 1:53 PM, Devin Jeanpierre <<a href="mailto:jeanpierreda@gmail.com" target="_blank">jeanpierreda@gmail.com</a>><br>
> wrote:<br>
>><br>
>> > In Python 2 "print 'something', statement calls were unbuffered and<br>
>> > immediately appeared on screen.<br>
>><br>
>> No, they weren't.<br>
><br>
><br>
> --- cut py2print.py ---<br>
> from time import sleep<br>
><br>
> while 1:<br>
> sleep(1)<br>
> print ".",<br>
> --- cut ---<br>
><br>
> This produces one dot every second with Python 2.7.2 on Windows.<br>
><br>
>> Python doesn't do any extra buffering or flushing. Usually your<br>
>> terminal emulator line-buffers stdout. If you don't print a newline<br>
>> (in Python 2 OR 3) then it doesn't show up until you either flush<br>
>> (sys.stdout.flush()) or send a newline.<br>
><br>
><br>
> I assume you use Linux. Do you agree that for cross-platform language some<br>
> behavior should be made consistent?<br>
</div></div></blockquote></div><br>