What values can be dictionary keys?
📁 Advanced Python Topics, Error
The documentation says that only immutable data types can be used as keys. Why doesn't an error occur in this case?
class Test: passt = Test()print({t: 1}) This is a paradigm that you can use everywhere or not use at all. It has its pros and its cons. But there is no magical threshold for when to use it or when not to use it.
Among the main advantages, it can be noted that the program is divided into classes that are responsible only for their own section of code. At the same time, abstraction hides internal details that you don't need to know. Therefore, large and complex programs become easier to understand and debug. You will know exactly where everything is located, provided you don't make mistakes.
Among the disadvantages is the complexity of design, because before writing you need to think through your data model very carefully. Sometimes this can take a lot of time and effort, especially if you're not used to it.
Classes can indeed be
Log in to leave an answer