← Back to team overview

openerp-expert-framework team mailing list archive

Re: Updated OpenERP API in trunk: fields.function, osv loading

 

On 07/04/2011 05:19 PM, Leonardo Santagada wrote:
> I saw the changeset[1], but why not introspect the function to know if
> it is a method or a function?

Because it doesn't matter. All we care about is a callable with the
right interface. It can be a function, a method, a lambda, a class
instance with a __call__ method, whatever, as long as it has the right
signature. So why bother?

And by the way, whenever you refer to a class method object within a
class definition, you directly get a function, not a method (yet). So we
were not even passing methods, even if it looked like we did.

>>> class MyClass(object):
...     def foo(self, bar):
...             pass
...     spam = {'foo': foo}
...
>>> MyClass.foo
<unbound method MyClass.foo>
>>> MyClass.spam['foo']
<function foo at 0x2082938>


References