Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 11th, 2012  |  syntax: None  |  size: 0.28 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # -*- encoding: utf-8 -*-
  2. """
  3. Простейший селектор
  4. """
  5.  
  6. a = "first"
  7. b = "second"
  8. print 1 and a or b
  9.  
  10. print 0 and a or b
  11.  
  12. # evaluated from left to right, so the and is evaluated first.
  13.  
  14. # 0 and 'first' evaluates to False, and then 0 or 'second' evaluates to 'second'.