which datastructure for fast sorted insert?

notnorwegian at yahoo.se notnorwegian at yahoo.se
Sun May 25 18:49:16 EDT 2008


On May 25, 9:32 am, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> On Sun, 25 May 2008 00:10:45 -0700, notnorwegian wrote:
> > sets dont seem to be so good because there is no way to iterate them.
>
> Err:
>
> In [82]: for x in set(['a', 'b', 'c']):
>    ....:     print x
>    ....:
> a
> c
> b
>
> Ciao,
>         Marc 'BlackJack' Rintsch


i meant like set[pos], not iterate but access a specific position in
the set.

now i have to do:
s = toSet.pop()
toSet.add(s)

if i want to get the url of the next item in a set, how would i do
that?
i can do this with a list:

def scrapeSitesX(startAddress, toList, listPos):
return scrapeSites(toList[listPos], toList, listPos+1)
to use recursion with a list.
i can work around that but it doesnt get as elegant.



More information about the Python-list mailing list