On 12.12.2011 14:37, Andrea Crotti wrote: > On 12/12/2011 01:27 PM, Henrik Faber wrote: >> Hi group, >> >> I'm a bit confused regarding decorators. Recently started playing with >> them with Python3 and wanted (as an excercise) to implement a simple >> type checker first: I know there are lots of them out there, this is >> actually one of the reasons I chose that particular function (to compare >> my solution against other, proven solutions). > > Not sure how that could work in general, what does "bar: str" should do? > Is that a dictionary?
No. It's PEP 3107 function annotations. > Anyway there is already an implementation if you're interested for type > checking: > http://oakwinter.com/code/typecheck/ *sigh* no, not really -- this is exactly why I wrote "I know there are lots of them out there". I've actually seen and run http://code.activestate.com/recipes/577299-method-signature-type-checking-decorator-for-pytho/ However, this doesn't do it for me -- I want to know why my solution fails, not just use some other solution without really understanding it. I really would like to understand what's going on. I'm especially puzzled about the fact that in my solution, __call__ is called with only the method's arguments (i.e. "fooobar") in my example instead of two arguments (self, "fooobar"). Best regards, Henrik -- http://mail.python.org/mailman/listinfo/python-list