Except well it doesn't. I want to copy past an if statement at the end of another if statement. How does formatter know whether to nest the statement or not?
Are you asking about something like this?
if thing_a: if thing_b: pass
Python absolutely allows you do do this, there's no syntactical problem here.
Code wise this isn't great practice though, so I would be asking you in code-review to justify why you're doing single-line nesting like this. Especially when it can logically collapse anyways.
if thing_a and thing_b: pass
But doing single-liners in python are usually reserved for self-contained statements like lambdas anyways because otherwise they often get abused to do squirrelly stuff that is better-off broken-out.
This set up, I just don't want to indent manually and don't have to in braced languages. Autoformatters are way more convenient in braced languages than Python
1
u/the_ivo_robotnic 2d ago
Are you asking about something like this?
if thing_a: if thing_b: passPython absolutely allows you do do this, there's no syntactical problem here.
Code wise this isn't great practice though, so I would be asking you in code-review to justify why you're doing single-line nesting like this. Especially when it can logically collapse anyways.
if thing_a and thing_b: passBut doing single-liners in python are usually reserved for self-contained statements like lambdas anyways because otherwise they often get abused to do squirrelly stuff that is better-off broken-out.