Re:Type checking in Python
by willvarfar on Sunday May 18, 2014 @10:02AM
(#7763082)
I've been checking types in Python dynamically for years now. My library, Obiwan https://pypi.python.org/pypi/obiwan/1.0.2 uses type annotations, which I think nicer than decorators.
[ Parent
| on HN ]
As the article mentions - the big advantage of decorators is Python 2.x compatibility. (not that I want to start another discussion of THAT topic)
EDIT - looks like obiwan will allow decorators as well as annotations. I do prefer the syntax of typedecorator though. It seems less cluttered.
It's a matter of taste. I think the decorator approach looks more bolted-on and ad hoc. I prefer C style declarations over annotations, though, because they have the least amount of noise.