title: List of combinations
body: <p>I have a list with length N and each element of this list are 0 or 1.
  I need to get all possible combinations of this list.  Here is my code:</p>
  
  <pre><code>def some(lst):
      result = []
      for element in lst:
          c1 = copy.copy(element)
          c2 = copy.copy(element)
          c1.append(0)
          c2.append(1)
          result.append(c1)         
          result.append(c2)
      return result
  
  def generate(n):
     if(n == 1):
         return [[0], [1]]
     else:
          return some(generate(n - 1))    
  
  print generate(4)
  </code></pre>
  
  <p>I think there is a more pythonic solution of this task.
  Thanks in advance.</p>