Re: duck typing assert‏

2012-11-09 Thread Terry Reedy
On 11/9/2012 1:30 AM, Steven D'Aprano wrote: On Thu, 08 Nov 2012 23:44:54 -0500, Terry Reedy wrote: On 11/8/2012 6:40 PM, Steven D'Aprano wrote: [...] IFoo.bar # returns a computed property Assuming IFoo is a class and bar is a property attribute of the class, IFoo.bar is the property obje

Re: duck typing assert‏

2012-11-08 Thread Steven D'Aprano
On Thu, 08 Nov 2012 23:44:54 -0500, Terry Reedy wrote: > On 11/8/2012 6:40 PM, Steven D'Aprano wrote: [...] >> IFoo.bar # returns a computed property > > Assuming IFoo is a class and bar is a property attribute of the class, > IFoo.bar is the property object itself, not the computed property of

Re: duck typing assert‏

2012-11-08 Thread Terry Reedy
On 11/8/2012 6:40 PM, Steven D'Aprano wrote: On Thu, 08 Nov 2012 15:39:24 -0500, Terry Reedy wrote: [...] test.py:21: UserWarning: 'bar': is not property. assert looks(Foo).like(IFoo) Traceback (most recent call last): File "test.py", line 21, in assert looks(Foo).like(IFoo) Asser

Re: duck typing assert‏

2012-11-08 Thread Steven D'Aprano
On Thu, 08 Nov 2012 15:39:24 -0500, Terry Reedy wrote: [...] > test.py:21: UserWarning: 'bar': is not property. >assert looks(Foo).like(IFoo) > Traceback (most recent call last): >File "test.py", line 21, in > assert looks(Foo).like(IFoo) > AssertionError > ''' > > I view this check

Re: duck typing assert‏

2012-11-08 Thread Steven D'Aprano
On Thu, 08 Nov 2012 20:34:58 +0300, Andriy Kornatskyy wrote: > People who come from strongly typed languages that offer interfaces > often are confused by lack of one in Python. Python, being dynamic > typing programming language, follows duck typing principal. It can as > simple as this: >   > as

Re: duck typing assert‏

2012-11-08 Thread Terry Reedy
On 11/8/2012 12:34 PM, Andriy Kornatskyy wrote: People who come from strongly typed languages that offer interfaces often are confused by lack of one in Python. Python, being dynamic typing programming language, follows duck typing principal. It can as simple as this: assert looks(Foo).like(IFo

duck typing assert‏

2012-11-08 Thread Andriy Kornatskyy
People who come from strongly typed languages that offer interfaces often are confused by lack of one in Python. Python, being dynamic typing programming language, follows duck typing principal. It can as simple as this:   assert looks(Foo).like(IFoo)   The post below shows how programmer can as