A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-April/078490.html below:

print function treats sep=None and end=None in an unintuitive way

[Python-Dev] py3k: print function treats sep=None and end=None in an unintuitive wayNick Coghlan ncoghlan at gmail.com
Tue Apr 8 15:57:08 CEST 2008
Alessandro Guido wrote:
> Can anybody please point me why print('a', 'b', sep=None, end=None) should
> produce "a b\n" instead of "ab"?
> I've read http://docs.python.org/dev/3.0/library/functions.html#print, pep-3105 and some
> ml threads but did not find a good reason justifying such a strange behaviour.

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

sep=None, end=None means "use the default separator and line ending" 
rather than "don't use a separator or line ending" (this is the same as 
for most functions with optional arguments - you need to look at the 
documentation of the function to find out what default values are used 
when passing None for an optional argument).

That said, it does read oddly, so I'd advise against writing it out 
explicitly like that - if you want the default, just leave out the 
relevant argument.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4