The Python Oracle

'and' (boolean) vs '&' (bitwise) - Why difference in behavior with lists vs numpy arrays?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 Question
01:35 Accepted answer (Score 152)
03:25 Answer 2 (Score 32)
08:18 Answer 3 (Score 23)
10:34 Answer 4 (Score 20)
14:07 Thank you

--

Full question
https://stackoverflow.com/questions/2264...

Question links:
[This answer]: https://stackoverflow.com/a/6490106/2098...
[this answer]: https://stackoverflow.com/a/10246441/209...
[and]: http://docs.python.org/2/library/stdtype...
[&]: http://docs.python.org/3/reference/expre...
[bitwise operations]: https://wiki.python.org/moin/BitwiseOper...

Answer 3 links:
[and]: http://docs.python.org/2/library/stdtype...
[empty lists]: http://docs.python.org/2/library/stdtype...
[binary literal]: http://docs.python.org/2/reference/lexic...
[arithmetic operations]: http://docs.scipy.org/doc/numpy/referenc...
[can't overload logical operators in python]: https://stackoverflow.com/a/471561/65295
[unix permission bits]: https://stackoverflow.com/a/1861970/6529...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #numpy #bitmanipulation #booleanexpression #ampersand

#avk47