[Python-Dev] py3k: print function treats sep=None and end=None in an unintuitive way

Alessandro Guido alessandro.guido at gmail.com
Tue Apr 8 18:01:15 CEST 2008

Nick Coghlan wrote:
> So that print(a, b) does the right thing (i.e. matches the Python 2.x 
> print statement's behaviour)

AFAICS print(a, b) does the right thing because default values of "sep" and
"end" are ' ' and '\n' respectively, doesn't it?

Eric Smith wrote:
> Because None means 'use the default value'.  You probably want:
> print('a', 'b', sep='', end='')

I think this is a "not optimally designed" API
because you have to read the documentation to understand why

print('a', 'b', sep=None, end=None)

does not translate into the obvious:

«print strings 'a' and 'b' using no separator and no terminator»

but into:

«print strings 'a' and 'b' using the default separator and the default terminator»

However i'll just cope with it, Python is still the best language ;)

Thank you all for replying!

	-Alessandro Guido

More information about the Python-Dev mailing list