Marek Mosiewicz <marek.mosiew...@jotel.com.pl> writes: > ... > I know that Python 3 has possibility to have indicate > type for varibale or param > What could be great to have possibility to annotate any > class with what I call "type evaluator" function. > That could check method signature with rules specific > for given type. > The simplest evaluator would simply check if signature > is same as method definition. > But it could go futher. It could check whatever is valid > logic for creating methods in given class and whatever > are valid params for given method. > Even more powerful evaluator could be not only > valid/not valid indicator. It could validate > and suggest next param or method part name for given > written part of call. That could make python IDEs > much more powerful > From my experience having signature checking and > hinting params when writing code is really big win.
You *can* do all that in Python -- even though you need something beyond what Python typically comes with. First, you need a formalisms to describe what should be checked. There are various alternatives: I am using "zope.interface" (to describe method signatures) and "zope.schema" (to describe the "type" of attributes). Next, you need something that does the checking. Again, there are alternatives. I prefer to check things in test suites -- and not permanently during productive use. But, Python has the powerfull "metaclass" concept. A metaclass allows you to customize class construction and e.g. to instrument all defined methods to perform automatic checks. -- https://mail.python.org/mailman/listinfo/python-list