We're a place where coders share, stay up-to-date and grow their careers.
So I will end up having nested try? As in
try: foo except FooException: print "foo" else: try: bar except BarException: print "bar" else: try: # ... so on so forth
?
potentially! but like i said, it might be worth refactoring those cases into separate functions
So
def wrap_foo: try: foo catch FooException: print "foo" def wrap_bar: # same as above def main: wrap_foo wrap_bar
Am I getting there?
yeah, depending on what you're trying to do—if everything's decoupled and bar doesn't depend on the success of foo, then this approach is the way to go
bar
foo
So I will end up having nested try? As in
?
potentially! but like i said, it might be worth refactoring those cases into separate functions
So
Am I getting there?
yeah, depending on what you're trying to do—if everything's decoupled and
bar
doesn't depend on the success offoo
, then this approach is the way to go