Closed v1a0 closed 3 years ago
__and__
Implements the &
operator not and
keyword.
__or__
means |
not or
.
(if that's what you meant)
__and__
Implements the&
operator notand
keyword.__or__
means|
notor
. (if that's what you meant)
Not really, I'm taking about: or
and |
don't work the same, it returns different values for same inputs
upd: yup
print(
(id_ < 1) or (id_ == 1)
)
# "('t1'.'id'=1)"
print(
(id_ < 1) | (id_ == 1)
)
# "(('t1'.'id'<1) OR ('t1'.'id'=1))"
type(id_) == SQLite3xColumn
[1,2,3] and [3,2,1]
# [3, 2, 1]
[] and [3,2,1]
# []
[] or [3,2,1]
# [3, 2, 1]
"test" or "something"
# 'test'
bool([])
# False
False or True
# True
5 | 2
# 7
5 or 2
# 5
or
and |
are different type of operators.
I think that this article might be helpful.
Wow, I didn't know that.
So is there exists some __method__
for class to override how or
works for this class?
Like __or__
method override instruction for |
operator.
Yes but __bool__
have only one argument.
I don't know why but it doesn't works with
and
,or
, but works great with|
,&
.urs_id: SQLite3xColumn
I'll open an issue about whit bug, but it's not really critical and necessary.