Decorator for Enforcing Argument Types

Chris chrisspen at gmail.com
Thu Dec 21 16:06:33 EST 2006


On Dec 21, 3:57 pm, "Paul McGuire" <p... at austin.rr._bogus_.com> wrote:
> "Chris" <chriss... at gmail.com> wrote in messagenews:1166734180.455471.164910 at 79g2000cws.googlegroups.com...
>
> > I'm not sure if this has been done before, but I couldn't easily find
> > any prior work on Google, so here I present a simple decorator for
> > documenting and verifying the type of function arguments.
> > Feedback/suggestions/criticism is welcome.They Python wiki has a page for decorator ideas/submissions, compare yours
> to this one:http://wiki.python.org/moin/PythonDecoratorLibrary#head-308f2b3507ca9...

Thanks, I was unaware of that page. I designed mine allow for
introspection, so the program can explicitly "see" what types a
function takes and test argument combinations if need be, which that
example doesn't seem to allow. Mine also supports multiple types per
argument. However, I like how that one also checks the return value.

Chris




More information about the Python-list mailing list