This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients lopgok, serhiy.storchaka
Date 2018-01-08.16:07:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515427658.88.0.467229070634.issue32520@psf.upfronthosting.co.za>
In-reply-to
Content
print() converts all its arguments to string by calling str(). The resulting strings are written to the output file.

print(bin_buff, file=fp) is equivalent to

    fp.write(str(bin_buff))
    fp.write('\n')

If you will run Python with options -b or -bb you will get a warning or an error from str(bin_buff) because this operation can be ambiguous. It is better to use an explicit repr() for converting bytes to str if you want to get the representation of the bytes object as a Python literal, or convert it to a string with specifying explicit encoding: str(bin_buff, 'utf-8') or bin_buf.decode('utf-8').
History
Date User Action Args
2018-01-08 16:07:38serhiy.storchakasetrecipients: + serhiy.storchaka, lopgok
2018-01-08 16:07:38serhiy.storchakasetmessageid: <1515427658.88.0.467229070634.issue32520@psf.upfronthosting.co.za>
2018-01-08 16:07:38serhiy.storchakalinkissue32520 messages
2018-01-08 16:07:38serhiy.storchakacreate