Peter Otten wrote:
Jean-Michel Pichavant wrote:
Chris Kaynor wrote:
On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote:
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
Jean-Michel Pichavant wrote:
> Chris Kaynor wrote:
>> On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote:
>>
>>> 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 dependencie
Chris Kaynor wrote:
On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote:
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 fro
> >> for obj in objs:
> >> try:
> >> obj.make()
> >> except Exception:
> >> continue
> >> else:
> >> break
> >> else:
> >> raise RuntimeError('No object worked')
> >
> >
> > I think you misunderstand the else clauses.
> >
> for obj in [ 1,2,3,4 ]:
> > ..
On Wed, May 2, 2012 at 1:12 PM, Prasad, Ramit wrote:
>> > 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
>
> > 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..
Forgot to add that all this is covered in the tutorial in the official docs:
http://docs.python.org/tutorial/controlflow.html#for-statements
--
CPython 3.3.0a3 | Windows NT 6.1.7601.17790
--
http://mail.python.org/mailman/listinfo/python-list
Why wouldn't a for loop work? If something works, you can break out,
otherwise continue.
working_obj = None
for obj in iterable:
try:
obj.do_something()
working_obj = obj
break
except:
continue
--
CPython 3.3.0a3 | W
On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote:
> 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,
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
ra
10 matches
Mail list logo