In article <3f26a2f1-94cf-4083-9bda-7076959ad...@k19g2000yqg.googlegroups.com>,
Darren Dale  <dsdal...@gmail.com> wrote:
>
>class Test(object):
>    @accepts(int)
>    def check(self, obj):
>        print obj
>
>t = Test()
>t.check(1)
>
>but now I want Test.check to accept an instance of Test as well. Does
>anyone know how this can be accomplished? The following class
>definition for Test raises a NameError:
>
>class Test(object):
>    @accepts(int, Test)
>    def check(self, obj):
>        print obj

Are you using Python 2.6 or later?  You could probably write a tricky
class decorator that re-wraps all wrapped methods....
-- 
Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of     
indirection."  --Butler Lampson
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to