title: for/empty loop condition in python
body: <p>In Django templates, <code>For loop</code> has a <code>empty</code> conditions which gets set only when the object you are looping over is empty.
  e.g:</p>
  
  <pre><code>{% for x in my_list %}
      #do something
  {% empty %}
     &lt;p&gt;  my_list is empty &lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>here if my_list is empty then it will just print <code>my_list is empty</code></p>
  
  <p>Is there something equivalent in python?</p>
  
  <p>I am using if-else conditions but that's ugly looking. I am trying to find a solution that does not involve using a if-else condition</p>
  
  <p>my current code:</p>
  
  <pre><code>if len(my_list):
     for x in my_list:
         doSomething()
  else:
      print "my_list is empty"
  </code></pre>