User:Xvedejas/Useful Hints

Simulate Abstract Fields
Like in C#, we want subclasses to re-implement our methods, so the solution is to raise a nice error if they do not override them.

Not Implemented Error
In smalltalk, objects have a method called "notImplemented" that is called whenever the object doesn't know what to do with a message it receives. In python we have __getattr__, which is also called when a method is not found.

>>> MyClass.test good >>> MyClass.testabcdefg not good, testabcdefg not found

Save/Load Datatype
Contents can literally be any built-in datatype, be it a list or dictionary(or any type that implements __repr__ and works with eval); and it will appear just like that type in every way except that added functionality

Auto Save/Load Dictionary
This dictionary tries to read/write to a file every single time you change it. I'm sure there's a purpose for something like this...

Note: This *is* sort of a hack, anything that modifies the dictionary needs to be reimplemented.