title: R function rep() in Python (replicates elements of a list/vector)
body: <p>The R function rep() replicates each element of a vector:</p>
  
  <pre><code>&gt; rep(c("A","B"), times=2)
  [1] "A" "B" "A" "B"
  </code></pre>
  
  <p>This is like the list multiplication in Python:</p>
  
  <pre><code>&gt;&gt;&gt; ["A","B"]*2
  ['A', 'B', 'A', 'B']
  </code></pre>
  
  <p>But with the rep() R function it is also possible to specifiy the number of repeats for each element of the vector:</p>
  
  <pre><code>&gt; rep(c("A","B"), times=c(2,3))
  [1] "A" "A" "B" "B" "B"
  </code></pre>
  
  <p>Is there such a function availbale in Python ? Otherwise how could one define it ? By the way I'm also interested in such a function for duplicating rows of an array.</p>