pairs from a list

Matthew_WARREN at bnpparibas.com Matthew_WARREN at bnpparibas.com
Thu Jan 24 05:23:45 EST 2008


:) I knew it was too simple to be true

and appropriately slows down when corrected, dang.

:)

Matt.


                                                                                                                                        
           Internet                                                                                                                     
           __peter__ at web.de                                                                                                             
                                                                                                                                     To 
                                                                        python-list                                                     
           Sent by:                                                                                                                  cc 
           python-list-bounces+matthew.warren=uk.bnpparibas.com@                                                                        
           python.org                                                                                                           Subject 
                                                                        Re: pairs from a list                                           
           23/01/2008 18:32                                                                                                             
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        




Matthew_WARREN wrote:

> I'm just fiddling with this, am no great expert, but I added
>
> def pairs5(x):
>         o=[]
>         for n in zip(x[::2],x[1:2]):

The second argument should be x[1::2].

>                 o.append(n)
>         return o
>
> I dont know if that breaks any constraints placed on the problem, but I

It breaks the constraints unless the above is not cut-n-paste ;)
Also note that your pairs5() offers no advantage over

def pairs6(x):
    return zip(x[::2], x[1::2])

Peter
--
http://mail.python.org/mailman/listinfo/python-list



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.



More information about the Python-list mailing list