Priority of the logical statements NOT AND & OR in python -


as far know, in c & c++, priority sequence not , & or not>and>or. doesn't seem work in similar way in python. tried searching in python documentation , failed (guess i'm little impatient.). can clear me?

it's not, and, or, highest lowest according documentation https://docs.python.org/3/reference/expressions.html#operator-precedence

here complete precedence table, lowest precedence highest. row has same precedence , chains left right

  1. lambda
  2. if – else
  3. or
  4. and
  5. not x
  6. in, not in, is, not, <, <=, >, >=, !=, ==
  7. |
  8. ^
  9. &
  10. <<, >>
  11. +, -
  12. *, /, //, %
  13. +x, -x, ~x
  14. **
  15. x[index], x[index:index], x(arguments...), x.attribute
  16. (expressions...), [expressions...], {key: value...}, {expressions...}

edit: had wrong precedence


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -