Friday, September 6, 2013

unicodebreakers

Just when you thought it was safe to unicode....
>>> unicode(3)
u'3'
>>> unicode(3, errors='replace')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: coercing to Unicode: need string or buffer, int found

If you prefer Python3:
>>> str(3)
'3'
>>> str(3, errors='replace')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: coercing to str: need bytes, bytearray or buffer-like object, int found

3 comments:

  1. Yes, str is really two functions in one. print(str.__doc__) will tell you how it's used.

    ReplyDelete
  2. Different mill saddlery staff endpoints, codes and approaches looking thrilling of view, travel, stray pieces, ... Unequivocal endpoints, cashback and vouchers for NHS and Healthcare Workers.

    ReplyDelete