[Python-3000] iostack and Oh Oh (original) (raw)
Bill Janssen janssen at parc.com
Fri Dec 1 17:31:15 CET 2006
- Previous message: [Python-3000] iostack and Oh Oh
- Next message: [Python-3000] Low-hanging fruit: change interpreter prompt?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Instinctively, I agree with Tomer on this issue. But I'm reasonably relaxed about the matter as long as it's optional. What I'm not sure about, is if that is the intention. For example,
class MyMap: def getitem(self, key): ... def setitem(self, key, value): ... If I pass this into a function (written by a 3rd party, so I have no way of changing it) that only uses the syntax m[k] on it (never needs to do len(m), or m.keys() or anything else), will it work? Please note that MyMap is deliberately written to not conform to any of your proposed base classes.
Paul,
So long as the third-party function only uses m[k] on it (and m[k] is implemented through getitem, as it presumably would be), why wouldn't it? I'm not suggesting generic functions which do interface-based method dispatch (though we may want to do that in the future).
There could be issues regarding operators, I agree. For instance, the [k] operation may be implemented by the Container interface generic implementation, in which case your type might have to have the Container interface, which currently means it would have to support len and contains, as well. But I think that's a separable discussion, about the locality of operator implementation.
Bill
- Previous message: [Python-3000] iostack and Oh Oh
- Next message: [Python-3000] Low-hanging fruit: change interpreter prompt?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]