[docs] [issue16011] "in" should be consistent with return value of __contains__

Neal Parikh report at bugs.python.org
Mon Sep 24 20:18:19 CEST 2012

Neal Parikh added the comment:

Thanks for passing along the thread, it was interesting. Oddly, it seemed to die off with no real resolution.

I realize it is now too late to change __contains__ to return a non-boolean value, but for reference, the reason I wanted to return something different from __contains__ was also to implement a DSL, though not a SQL-related one. Basically, I have some kind of abstract mathematical set S, and I wanted "x in S" to return a constraint that the variable x must lie in the set S for use in a larger problem description. (In fact, one could implement __contains__ so it returned True/False with a constant numeric argument and a constraint object with a variable argument.) This would have mirrored the way one would write all this mathematically.


Python tracker <report at bugs.python.org>

More information about the docs mailing list