Problem with the sort() function

Sion Arrowsmith siona at chiark.greenend.org.uk
Tue Feb 22 07:32:12 EST 2005


clementine <kashmira_v_phalak at yahoo.com> wrote:
>Thanx Nick...I forgot to mention im using python 2.2 and along with a host
>of other things it doesnt seem to have the enumarate built in function
>:(:(:(...is it possible to replace it by something else? I dont think
>simulating it will be feasible....

Here's one I prepared earlier:

if sys.version_info < (2,3):
    def enumerate(l):
        return zip(range(len(l)), l)

which will suck somewhat on large lists compared to being able to
do it with iterators.

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list