Why Python language does not have a writeln() method?

systempuntoout picture systempuntoout · Apr 4, 2010 · Viewed 24.8k times · Source

If we need to write a new line to a file we have to code:

file_output.write('Fooo line \n')

Are there any reasons why Python does not have a writeln() method?

Answer

Daniel Stutzbach picture Daniel Stutzbach · Apr 4, 2010

In Python 2, use:

print >>file_output, 'Fooo line '

In Python 3, use:

print('Fooo line ', file=file_output)