Why not allow empty code blocks?

Chris Angelico rosuav at gmail.com
Sat Jul 30 08:34:24 EDT 2016


On Sat, Jul 30, 2016 at 10:27 PM, BartC <bc at freeuk.com> wrote:
>> where the print function allows full customization
>> of both end= and sep=.
>
>
> This is one thing I can never get right in Python: controlling when a
> newline is or isn't generated and what happens with separators.
>
> (In fact when I used Python as a target language, I had to generate calls to
> sys.stdout.write instead as it had more predictable behaviour.)
>
> So if it's the advantage of using () then it's one I never benefit from!
>
> Newline control should be one of the simplest things in the language, part
> of the very first programs you write.
>
> (Some languages use 'write' or 'writeln', or 'print' or 'println'; what
> could be simpler? Or you just explicitly output a "\n" string.)

Here, look:

print(obj) # with newline
print(obj, end="") # without newline

Easy, isn't it?

Start playing to the language's strengths instead of fighting against
them. Keyword arguments are a Python feature that I frequently yearn
for in other languages. Use them!

ChrisA



More information about the Python-list mailing list