[Zope3-dev] Re: adapter registration question

Tres Seaver tseaver at palladion.com
Mon Nov 13 13:10:39 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Philipp von Weitershausen wrote:
> Tres Seaver wrote:

<snip>

>> Thnk of cataloguing / indexing use cases:  adapting the catalogued
>> object to a string value (or tuple, or whatever) using named adapters is
>> a very "natural" way to make indexing pluggable:  what is *unnatural*
>> (or at least a "dead chicken") is the requirement to adapt to an
>> 'IString', when what I really want is a 'str'.
> 
> Well, part of Python idea is duck typing and requiring that you get a 
> 'str' may be too much. Perhaps you would really only like to get 
> something that quacks like str. OTOH, perhaps you absolutely want a 
> 'str' and that use case should perhaps be allowed...

Heh, in this case using 'IString' is really a "trussed duck" (duck
typing with B&D) ;)  Python's duck typing breaks down with strings,
because they can by "quack tested" like sequences, but you almost
*never* want to treat them the same way as other sequences, so you end
up with 'isinstance(obj, basestr)' tests to prevent handling them that way.


Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFWLUf+gerLs4ltQ4RAt/1AKCUvR230iCgNOq7kUpqAcFrSQVp5wCfedXY
WI/ty3z7ektpMS/9Mh+l/PI=
=IM7g
-----END PGP SIGNATURE-----



More information about the Zope3-dev mailing list