[Tutor] try except block for multiple statements

Kent Johnson kent37 at tds.net
Sun Dec 7 20:45:12 CET 2008


On Sun, Dec 7, 2008 at 12:25 PM, Lie Ryan <lie.1296 at gmail.com> wrote:

> texts = ["a = %s\n" % plan.a,
>         "b = %s\n" % plan.b,
>         "c = %s\n" % plan.c,
>         "d = %s\n" % plan.d
>        ]
>
> for text in texts:
>    try:
>        fo.write(text)
>    except AttributeError:
>        pass

No, the AttributeError will come during the creation of texts, not in the loop.

Kent


More information about the Tutor mailing list