Python pearls required for iteration across fields of data structure

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Jul 24 06:14:57 EDT 2007


On Tue, 24 Jul 2007 02:26:15 -0700, NetHead wrote:

> The code below is WRONG, but hopefully illustrates what I am trying to
> achieve.
> 
> Any suggestions how to code this is an efficient and maintainable (and
> correct) manner?
> 
> […]
> for i in wildcards:
>         for j in i:
>                 try:
>                         j = self.replaceFieldsAndIndices(j, rcn, rcu,
> rcp, indices)
>                 except:
>                         # Ignore errors if condition has no format.
>                         pass

Maybe you shouldn't silence all exceptions with a bare except here.  This
swallows any errors in `replaceFieldsAndIndices()`.  Maybe some of them
are not the exception you expect, but real errors in your program!?

Ciao,
	Marc 'BlackJack' Rintscj



More information about the Python-list mailing list