Найти - Пользователи
Полная версия: Dict update override
Начало » Python для новичков » Dict update override
1
NSkrypnik
Интересно. Вот такой просто код:
class myDict(dict):
def update(self, *args):
super(myDict, self).update(self, *args)
return self

boo = myDict()
boo = {'a': 1, 'b': 2}
s = boo.update({'c': 3})
print s
Я думал, что он выведет {'a': 1, ‘b’: 2, ‘c’: 3}, но в итоге получается None. Не могу понять почему и как получить содержимое словаря.
doza_and
все очень просто
после
boo = {'a': 1, 'b': 2}
это уже не ваш словарик а обычный
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB