PEP 0214 - extended print statement
Martijn Faassen
m.faassen at vet.uu.nl
Wed Aug 23 07:45:00 EDT 2000
Richard Jones <Richard.Jones at fulcrum.com.au> wrote:
> [Barry A. Warsaw]
>> Please be aware that Guido has ruled favorably on PEP 214, the
>> extended print statement. This feature has been accepted as described
>> in the PEP[1] and is now checked into the Python 2.0 development
>> tree.
> ... Well, I'm stunned ...
Me too; print was already odd with its special treatment of the ',':
print "foo",
And now it's even odder, throwing in a special meaning for >>. I hope that
this kind of syntax extension isn't the trend with Python now.
Suddenly we're directing output with >>, and we never did before.
The writeln() approach seems better, and even better would be to
attach it to the file class like this:
f.writeln(...)
Though I tend to handle this type of 'write to logfile' thing with a
convenient log object like this:
class Log:
def __init__(self, f):
self.f = f
def __call__(self, line):
self.f.write(line)
self.f.write("\n")
mylog = Log(sys.stdout)
mylog("foo!")
If I need any automatic conversions to strings, I just use % with %s.
Anyway, perhaps this change makes print more useful, but it sure looks
ugly to me.
Regards,
Martijn
--
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?
More information about the Python-list
mailing list