Philipp von Weitershausen wrote:

...hence the quotes. It's a "function" in that I want to use it as an adapter that doesn't need to be instantiated by a factory before being used.

All adapters need to be instantiated.


def myStrAdapter(something):
   return str(something)

This function adapts strings to integers, why would it need to be instantiated?

No. You always register a factory which is called upon lookup. That's because adapters are context-dependent and thus need to be instantiated every time you look them up.

What if they're not context-dependent as in my example above?

ultimately, I'm looking to replace code like the following:

convertors = {

def convert(x,y):
   return convertors[type(x)][type(y)](x)

...if you see what I mean. Apologies for the trivial examples, but these are real problems...



Simplistix - Content Management, Zope & Python Consulting

Zope3-dev mailing list

Reply via email to