Hidden features of Python -


what lesser-known useful features of python programming language?

  • try limit answers python core.
  • one feature per answer.
  • give example , short description of feature, not link documentation.
  • label feature using title first line.

quick links answers:

chaining comparison operators:

>>> x = 5 >>> 1 < x < 10 true >>> 10 < x < 20  false >>> x < 10 < x*10 < 100 true >>> 10 > x <= 9 true >>> 5 == x > 4 true 

in case you're thinking it's doing 1 < x, comes out true, , comparing true < 10, true, no, that's not happens (see last example.) it's translating 1 < x , x < 10, , x < 10 , 10 < x * 10 , x*10 < 100, less typing , each term evaluated once.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -