[Tutor] Replace try: except: finally:

Kent Johnson kent37 at tds.net
Fri Nov 20 16:47:04 CET 2009


On Fri, Nov 20, 2009 at 8:08 AM, Stephen Nelson-Smith
<sanelson at gmail.com> wrote:
> I need to make some code Python 2.4 compliant... the only thing I see
> is use of try: except: finally:
>
> To make this valid, I think I need to do a try: finally: and next try:
> except: inside.  Is this correct?

Yes, the backwards-compatible replacement for try: except: finally: is

try:
  try:
    ...
  except:
    ...
finally:
  ...

Kent


More information about the Tutor mailing list