Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Fw: Undeliverable Message

Reply
Thread Tools

Fw: Undeliverable Message

 
 
Matthew_WARREN@bnpparibas.com
Guest
Posts: n/a
 
      01-25-2008
Hallo pyPeople,

I wrote a little snippet of code that takes a list representing some
'digits', and according to a list of symbols, increments the digits through
the symbol list.

so for example,

digits=["a","a","a"]
symbols=["a","b","c"]


increment(digits,symbols) repeatedly would return digits as

aab
aac
aba
abb
abc
aca


etc..

Heres the code

def increment(digits,symbols):
overflow=True
digitpos=-1
while overflow and -digitpos<=len(digits):
digitsymbolindex=symbols.index(digits[digitpos])
if digitsymbolindex==len(symbols)-1:
overflow=True
digits[digitpos]=symbols[0]
digitpos=digitpos-1
else:
digits[digitpos]=symbols[digitsymbolindex+1]
overflow=False
return digits



Now, this works. All good. It's nice and simple. I'm just wondering how
anyone else might approach it?


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.


 
Reply With Quote
 
 
 
 
Bart Kastermans
Guest
Posts: n/a
 
      01-30-2008

On Jan 25, 5:05*am, (E-Mail Removed) wrote:
> Hallo pyPeople,
>
> I wrote a little snippet of code that takes a list representing some
> 'digits', and according to a list of symbols, increments the digits through
> the symbol list.
>
> so for example,
>
> digits=["a","a","a"]
> symbols=["a","b","c"]
>
> increment(digits,symbols) repeatedly would return digits as
>
> aab
> aac
> aba
> abb
> abc
> aca
>
> etc..
>
> Heres the code
>
> def increment(digits,symbols):
> * * * * overflow=True
> * * * * digitpos=-1
> * * * * while overflow and -digitpos<=len(digits):
> * * * * * * * * digitsymbolindex=symbols.index(digits[digitpos])
> * * * * * * * * if digitsymbolindex==len(symbols)-1:
> * * * * * * * * * * * * overflow=True
> * * * * * * * * * * * * digits[digitpos]=symbols[0]
> * * * * * * * * * * * * digitpos=digitpos-1
> * * * * * * * * else:
> * * * * * * * * * * * * digits[digitpos]=symbols[digitsymbolindex+1]
> * * * * * * * * * * * * overflow=False
> * * * * return digits
>
> Now, this works. All good. It's nice and simple. *I'm just wondering how
> anyone else might approach it?


I (not an expert at all) have only minor comments and one question:
comments:
why keep setting overflow to True, if you do not touch it will not
change.
digitpos -= 1 is easier to read in my mind
question:
Why first extract the indices and then compare (in your if statement),
and
why do you not just compare the symbols?

Best,
Bart
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaMail - Managing undeliverable feedback, notification himgi Java 5 03-10-2006 03:35 PM
Message Undeliverable! Mail Delivery Subsystem Python 0 02-10-2004 04:53 AM
undeliverable message reports Mark Computer Support 2 09-20-2003 05:15 PM
Re: undeliverable e-mails due to server error why? Computer Support 0 08-03-2003 06:45 PM
Re: undeliverable e-mails due to server error °Mike° Computer Support 0 08-03-2003 06:12 PM



Advertisments