how to append to a list twice?

Fredrik Lundh fredrik at pythonware.com
Fri Apr 21 11:52:31 EDT 2006


Alex Martelli wrote:

> > But of course that only does it once, and I don't want to have to copy
> > and paste the append line. Perhaps there's a better way than this.
>
> def makeseries(N):
>   series = [N]
>   append = series.append
>   for tailer in xrange(N-1, -1, -1):
>     append(tailer)
>     append(tailer)

But Now You've Violated The DRY Principle!!!

</F>






More information about the Python-list mailing list