duck(Foo).match(IFoo, <kwargs>) duck(Foo).like(IFoo, <kwargs>)
Hm... function name in most cases is read as verb... this may cause confusion: duck => synonyms => immerse, dip Thanks. Andriy Kornatskyy ---------------------------------------- > From: ramit.pra...@jpmorgan.com > To: andriy.kornats...@live.com; python-list@python.org > Subject: RE: duck typing assert > Date: Fri, 9 Nov 2012 17:37:29 +0000 > > Andriy Kornatskyy wrote: > > > > Thank you for all comments. > > > > > It makes very good sense to say: > > > > > > duckmatch(IFoo).compare(Foo) > > > > Since we do duck match of IFoo... but there is no `duck match`, there is > > `duck test`. I believe instead of > > `compare` is more readable with `equals`. Than it is more from mathematics > > - precise answer... that you can not > > guarantee at all in dynamic programming language. So it false to use such > > wording to reflect this check. We can > > only make an assumption that one looks like the other (similar)... with > > some limitation of cause... > > understanding what is `duck test`. > > > > http://en.wikipedia.org/wiki/Duck_test > > > > The intent is to make such language `construct` so it reads as English > > sentence that make sense, and not > > mandatory `pythonic` way (readability counts, java smokes aside). > > > > is_similar(Foo).to(IFoo) # <= but we lost `duck test` sense here? > > > > Words `looks` and `like` are coming from duck test and point also direction: > > > > # 1 > > looks(Foo).like(IFoo, notice=['__len__'], ignore_funcs=['foo'], > > ignore_argspec['bar']) > > > > English sentence equivalent: if functions in Foo looks like one in IFoo > > than, probably, IFoo can be replaced > > with Foo; notice to check __len__, it is safe to ignore function `foo` and > > arguments passed to `bar`. > > > > # 2 > > looks(Foo, notice=['__len__'], ignore_funcs=['foo'], > > ignore_argspec['bar']).like(IFoo) > > > > English sentence equivalent: while looking at Foo notice to check > > `__len__`, it is safe to ignore function `foo` > > and arguments passed to `bar`, than probably it like IFoo. > > What about? > > duck(Foo).equivalent_to(IFoo, <kwargs>) > duck(Foo).matches(IFoo, <kwargs>) > > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities, accuracy and completeness of information, viruses, > confidentiality, legal privilege, and legal entity disclaimers, > available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list