On 16/12/2022 02.30, Rob Cliffe via Python-list wrote:
On 15/12/2022 04:35, Chris Angelico wrote:
On Thu, 15 Dec 2022 at 14:41, Aaron P <transreduction...@gmail.com> wrote:
I occasionally run across something like:

for idx, thing in enumerate(things):
     if idx == 103:
         continue
     do_something_with(thing)

It seems more succinct and cleaner to use:

if idx == 103: continue.


Nothing at all wrong with writing that on a single line. If you have
issues with Flake8 not accepting your choices, reconfigure Flake8 :)

ChrisA
I'm so glad that Chris and others say this.  It (i.e. if plus break/continue/return on a single line) is something I have quite often done in my own code, albeit with a feeling of guilt that I was breaking a Python taboo.  Now I will do it with a clear conscience. 😁

Anxiety doesn't help anyone - least of all you.

Remember another Python mantra: "we're all adults here"!

(also (compulsory interjection) PEP-008 is not a set of rules for all Python code - see PEP-008)

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to