[Python-de] Re: konstante Lists, Dictionaries
[email protected] (Stefan Ram) 27 Dec 2023 09:04:39 GMT
| Newsgroups | gmane.comp.python.general.german |
|---|---|
| Organization | Stefan Ram |
| Message-ID | <[email protected]> |
[email protected] (Stefan Ram) writes: >import collections >class dictionary( collections.UserDict ): > pass >class const_dict( dictionary ): > def __init__( self, other ): > self.data = other.data > def __setitem__( self, key, item ): > raise NotImplementedError Allerdings wäre danach issubclass( const_dict, collections.abc.MutableMapping ) wahr (/Mutable/!). Dies mag in der hier beschriebenen Anwendung kein Problem sein; aber um dies zu verhindern, könnte man "const_dict" auf collections.abc.Mapping bauen. _______________________________________________ python-de Mailingliste -- [email protected] Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an [email protected] https://mail.python.org/mailman3/lists/python-de.python.org/ Mitgliedsadresse: [email protected]