Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99932
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: how to make the below code look better |
| Date | 2015-12-03 17:23 +1100 |
| Message-ID | <mailman.157.1449123833.14615.python-list@python.org> (permalink) |
| References | <CACT3xuXH0j9owTTmyJzdQcEox9fD31tb=zK0dmXnbjiOjqcgUw@mail.gmail.com> <CAPTjJmr04BOCogG3i5SQ5jehqR6q5isHehv1peWEKJ3uj+vYOA@mail.gmail.com> <CACT3xuW22=hcmdByzUmYdfHQfixpmDgMB+Y-oKJyL7cTayVRaA@mail.gmail.com> |
On Thu, Dec 3, 2015 at 5:20 PM, Ganesh Pal <ganesh1pal@gmail.com> wrote: >> The first suggestion I'd make is to avoid the comma syntax for >> exception handling. Replace "except Exception, e:" with "except >> Exception as e:". That's a trivial change of syntax that shouldn't >> affect your code at all; consider it low-hanging fruit. >> > ,Are we avoiding comma syntax because it's a bad convention or will > it have any side effects? In fact I have used this comma syntax in > most of my code . I will clean the code latter as it seems working > fine > The comma syntax isn't supported in Python 3, so it'll be a barrier to migration. It's also a bit less clear if you catch multiple exception types in a single handler, which also uses a comma (to make a tuple). Also, the 'as' syntax matches up with similar syntax for 'with' and 'import' statements. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: how to make the below code look better Chris Angelico <rosuav@gmail.com> - 2015-12-03 17:23 +1100
csiph-web