Hi Albert,
Just following up: I consider the 2 (or 3) arg form of unicode() to be
a design flaw in the Standard Library. It's redundant because the
bytes type already has a decode() method:
https://docs.python.org/3/library/stdtypes.html#bytes.decode
So I would personally write convert() like this:
######################################
def convert(data):
if isinstance(data, float):
return unicode(data)
if isinstance(data, bytes):
return data.decode("utf-8")
raise ValueError("Unexpected data", data)
######################################
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor