[Python-Dev] PEP 246, redux (original) (raw)

Alex Martelli aleax at aleax.it
Wed Jan 12 19:04:04 CET 2005


On 2005 Jan 12, at 18:58, Phillip J. Eby wrote: ...

I have some data about people coming in from LDAP and the like, which I want to record in that SQL DB -- the incoming data is held in types that implement IPerson, so I write an adapter IPerson -> IFullname for the purpose. This doesn't answer my question. Obviously it makes sense to adapt in this fashion, but not IMPLICITLY and AUTOMATICALLY. That's the distinction I'm trying to make. I have no issue with writing an adapter like 'PersonAsFullName' for this use case; I just don't think you should register it for automatic use any time you pass a Person to something that takes a FullName.

I'm adapting incoming data that can be of any of a huge variety of concrete types with different interfaces. *** I DO NOT WANT TO TYPECHECK THE INCOMING DATA *** to know what adapter or converter to apply -- *** THAT'S THE WHOLE POINT *** of PEP 246. I can't believe we're misunderstanding each other about this -- there MUST be miscommunication going on!

So, I'm not sure why you appear to argue for conversion against adaptation, or explicit typechecking against the avoidance thereof which is such a big part of adapt's role in life. Okay, I see where we are not communicating; where I've been saying "conversion", you are taking this to mean, "don't write an adapter", but what I mean is "don't register the adapter for implicit adaptation; explicitly use it in the place where you need it.

"Adaptation is not conversion" is how I THOUGHT we had agreed to rephrase my unfortunate "adaptation is not casting" -- so if you're using conversion to mean adaptation, I'm nonplussed.

Needing to be explicit and therefore to typechecking/typeswitching to pick which adapter to apply is just what I don't WANT to do, what I don't want ANYBODY to have to do EVER, and the very reason I'm spending time and energy on PEP 246. So, how would you propose I know which adapter I need, without spreading typechecks all over my bedraggled CODE?!?!

Alex



More information about the Python-Dev mailing list