Longue histoire courte:__unicode __ (self) ne soit pas appelé en vous connectant
# this works as expected:
logging.error(my_object.__unicode__())
# this doesn't:
logging.error(my_object)
Même résultat avec __str__(self)
. Pourquoi?
EDIT: __str__
fonctionne réellement.
Pas vrai. La journalisation formatera le message en utilisant 'str (msg)% args'. Dans Python 2.x, vous devez toujours implémenter '__str __()' et '__unicode__' si vous voulez fournir un comportement stringify. –