def to_str(self):
"""
Due to the way python_2_unicode_compatible works, this does not work:
@python_2_unicode_compatible
class GoogleAccount(ProviderAccount):
def __str__(self):
dflt = super(GoogleAccount, self).__str__()
return self.account.extra_data.get('name', dflt)
It will result in and infinite recursion loop. That's why we
add a method `to_str` that can be overriden in a conventional
fashion, without having to worry about @python_2_unicode_compatible
"""
return self.get_brand()['name']
python类python_2_unicode_compatible()的实例源码
def to_str(self):
"""
Due to the way python_2_unicode_compatible works, this does not work:
@python_2_unicode_compatible
class GoogleAccount(ProviderAccount):
def __str__(self):
dflt = super(GoogleAccount, self).__str__()
return self.account.extra_data.get('name', dflt)
It will result in and infinite recursion loop. That's why we
add a method `to_str` that can be overriden in a conventional
fashion, without having to worry about @python_2_unicode_compatible
"""
return self.get_brand()['name']