Zanurkuj w Pythonie/Klasa opakowująca UserDict: Różnice pomiędzy wersjami
Usunięta treść Dodana treść
poprawa formatowania (wcześniej tłumaczenie) |
Nie podano opisu zmian |
||
Linia 9:
class UserDict:
def __init__(self, dict=None):
self.data = {}
if dict is not None: self.update(dict)
# Klasa <tt>UserDict</tt> jest klasą bazową, nie dziedziczy nic z innych klas.
Linia 28:
'''Przykład 5.10. Standartowe metody klasy <tt>UserDict</tt>'''
def clear(self): self.data.clear()
def copy(self):
if self.__class__ is UserDict:
return UserDict(self.data)
import copy
return copy.copy(self)
def keys(self): return self.data.keys()
def items(self): return self.data.items()
def values(self): return self.data.values()
|