List and generator - callers or functions responsibility
<p>When calling a function that accepts a list, who is responsible (caller - a user, or called - the function) to ensure that it is a <code>list</code> and not a <code>generator</code>? </p>

<p>An example:</p>

<pre><code>&gt;&gt;&gt; def print_collection(coll):
...     for element in coll:
...         print element

&gt;&gt;&gt; def print_collection_twice(coll):
...     print_collection(coll)
...     print_collection(coll)
</code></pre>

<p>With a list it will work without surprises:</p>

<pre><code>&gt;&gt;&gt; print_collection_twice( [x*2 for x in xrange(3)] )
0
2
4
0
2
4
</code></pre>

<p>And with a generator, obviously it is printed only once, which might lead to a nasty bug:</p>

<pre><code>&gt;&gt;&gt; print_collection_twice( (x*2 for x in xrange(3)) )
0
2
4
</code></pre>

<p>What is the <em>best practice</em> here? Should a function assume a list, and a user is responsable to provide the <code>list</code>, or should the function do always <code>real_list = list(input_list)</code> at the beginning so the user does not care?</p>

<p><strong>Edit</strong></p>

<p>I <em>know</em> how to check type of the element and <code>assert</code>, my question is rather high level</p>
