Python __call__ special method practical example
I know that __call__ method in a class is triggered when the instance of a class is called. However, I have no idea when I can use this special method, because one can simply create a new method and perform the same operation done in __call__ method and instead of calling the instance, you can call the method. I would really appreciate it if someone gives me a practical usage of this special method. Django forms module uses __call__ method nicely to implement a consistent API for form validation. You can write your own validator for a form in Django as a function. def custom_validator(value):