On Tue, Apr 16, 2013 at 6:17 PM, Dave Angel <[email protected]> wrote:
> Someone else may know if "identical" has some exceptions. But as for where
> to put it, you'd need it for any module (including your own script) which is
> going to use the newer print() function.
I think any differences will result from the I/O system redesign in
3.x. In 2.x sys.stdout is still the old "file" type, which is
basically a wrapper around CRT FILE streams, while in 3.x it's a
TextIOWrapper wrapping a BufferedWriter wrapping a FileIO object.
Off the top of my head I don't have a clear example where it matters.
I vaguely recall having an issue with the default buffer flushing not
being the same. I think I was simulating scrolling text by printing a
carriage return ('\r') to overwrite a line. IRRC, in the end I opted
to directly use sys.stdout.write() and sys.stdout.flush().
Since __future__ imports are compiler directive, you have to include
them at the top of every module. "print_function" works in 2.6+. If
you just want the function under a different name, you can grab it
from the __builtin__ module:
>>> import __builtin__
>>> printf = getattr(__builtin__, 'print')
>>> printf('spam')
spam
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor