1

I am finishing up a new Python library which, among other things, can read and write files and strings in a specific format. I thought it would be nice if the read/write functions were equipped to handle different encodings. The library is expected to work on 2.7 and some of the 3.x versions.

Naturally, running tox afterwards blew up because of the different ways that Python's different versions handle encodings.

My question is: What is the best way to handle file/string encodings in Python API design?

Currently, I am considering letting the user handle all encoding except for my write_string function which will take a list of entries, an optional encoding (perhaps defaulting to utf-8) and format the string accordingly. This makes sense because the function takes a list of entries and not a string.

NordCoder
  • 403
  • 1
  • 7
  • 21

0 Answers0