Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
try/except in a loop
 

Index | Next | Previous | View Flat


jmwebaze at gmail

May 2, 2012, 12:51 PM


Views: 503
Permalink
try/except in a loop

I have multiple objects, where any of them can serve my purpose.. However
some objects might not have some dependencies. I can not tell before hand
if the all the dependencies exsit. What i want to is begin processing from
the 1st object, if no exception is raised, i am done.. if an exception is
raised, the next object is tried, etc Something like

objs = [... ]
try:
obj = objs[0]
obj.make()
except Exception, e:
try:
obj = objs[1]
obj.make()
except Exception, e:
try:
obj = objs[2]
obj.make()
except Exception, e:
continue

The problem is the length of the list of objs is variable... How can i do
this?



--
*Mob UG: +256 (0) 70 1735800 | NL +31 (0) 6 852 841 38 | Gtalk: jmwebaze |
skype: mwebazej | URL: www.astro.rug.nl/~jmwebaze

/* Life runs on code */*

Subject User Time
try/except in a loop jmwebaze at gmail May 2, 2012, 12:51 PM
    Re: try/except in a loop ckaynor at zindagigames May 2, 2012, 12:58 PM
    Re: try/except in a loop bahamutzero8825 at gmail May 2, 2012, 1:07 PM
    Re: try/except in a loop bahamutzero8825 at gmail May 2, 2012, 1:10 PM
    RE: try/except in a loop ramit.prasad at jpmorgan May 2, 2012, 1:12 PM
    Re: try/except in a loop ckaynor at zindagigames May 2, 2012, 1:27 PM
    RE: try/except in a loop ramit.prasad at jpmorgan May 2, 2012, 2:00 PM
    Re: try/except in a loop jeanmichel at sequans May 3, 2012, 6:27 AM
        Re: try/except in a loop __peter__ at web May 3, 2012, 6:57 AM
            Re: try/except in a loop jeanmichel at sequans May 3, 2012, 7:54 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.