Home

Try adding all the functions into a list such as;

funcList = [dev.read1, dev.read2, dev.read3]

for func in funcList:
for dev in devs:
try:
func()
except:
print exception
remove dev from devs

Wes.

On 05/09/07, bambam <david@asdf.asdf> wrote:
> I have about 30 pages (10 * 3 pages each) of code like this
> (following). Can anyone suggest a more compact way to
> code the exception handling? If there is an exception, I need
> to continue the loop, and continue the list.
>
> Steve.
>
> -----------------------------------
> for dev in devs
> try:
> dev.read1()
> except
> print exception
> remove dev from devs
>
> for dev in devs
> try:
> dev.read2()
> except
> print exception
> remove dev from devs
>
> for dev in devs
> try:
> dev.read3()
> except
> print exception
> remove dev from devs
>
> etc.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

previous
next

Re: static member object initialization
Re: where are the .pyc files?
Re: which language allows you to change an argument's value?
Re: Specifying address of const overloaded function
Re: unsigned char ---- a special type of integer
Niechciane i Zapomniane
Podaruj Zycie
Mam Marzenie
Fundacja Avalon
Mimo Wszystko