On May 1, 2006, at 2:56 AM, Bernd Dorn wrote:

On 01.05.2006, at 01:55, Stephan Richter wrote:

On Sunday 30 April 2006 19:34, Bernd Dorn wrote:
component.queryMultiAdapter((bar,baz), IFoo) is not None or False

this way you always get True or False

ok, for this case it is ok

but when you have a class that uses __conform__ None may be returned when you use this


or am i wrong?

It might return None, which according to our semantics means that the adaptation failed. Since None has a False meaning in a boolean context, Stephan's version will work out. However...

Why not just:

component.queryMultiAdapter((bar,baz), IFoo, default=False)

...this assumes that the adapter evaluates to a boolean True, which is not generically (reliably) the case. As a pattern, Bernd's version is safer, although the trailing "or False" is superfluous.

component.queryMultiAdapter((bar,baz), IFoo) is not None

Zope3-users mailing list

Reply via email to