Alternate for range in python
<p>If I have to generate natural numbers, I can use 'range' as follows:</p>

<pre><code>list(range(5))
</code></pre>

<p>[0, 1, 2, 3, 4]</p>

<p>Is there any way to achieve this without using range function or looping?</p>

<p>Looping will be required in some form or another to generate a list of numbers, whether you do it yourself, use library functions, or use recursive methods.</p>

<p>If you're not opposed to looping in principle (but just don't want to implement it yourself), there are many practical and esoteric ways to do it (a number have been mentioned here already).</p>

<p>A similar question was posted here: <a href="http://stackoverflow.com/questions/8429794/how-to-fill-a-list">How to fill a list</a>.  Although it has interesting solutions, they're all still looping, or using <code>range</code> type functions.</p>

python