[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Traversing python datatypes via http

Matthew_WARREN

2/7/2008 10:51:00 AM








"Mark" <mobiledreamers@gmail.com> wrote

> > Is it possible to traverse say python lists via http://
>
> http is a network protocol.
> What does that have to do with traversing python lists?
> Can you clarify what you mean by that?
>
> > say there is a list in the memory
> > can we traverse the list using list/next list/prev list/first
> > list/last
>
> Not with a standard list although its not hard to do by defining
> your own class wrappibng a list.
>
> You can however traverse a list using a standard for loop:
>
> for item in [1,2,3,4,5]:
> print item
>
> And you can use range() to generate a set of indices
> that will allow you to iterate by more unusual step sizes

As well as range(), slicing can do;

for item in [1,2,3,4,5,6,7,8,9,0][::2]:
print item

1
3
5
7
9

for item in [1,2,3,4,5,6,7,8,9,0][::-2]:
print item

0
8
6
4
2


Matt.

--


This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
Do not print this message unless it is necessary,
consider the environment.

---------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.
N'imprimez ce message que si necessaire,
pensez a l'environnement.