r/pythontips • u/bhavaniravi • Oct 17 '21
Syntax Python Beginner Mistakes
As a Python trainer, I get to work with pynewbies across the spectrum. It doesn't matter whether they are from college or years into the industry when learning Python. The simplest language on the earth is not that intuitive. Things get even more challenging when they are well versed in a Typed-Object-Oriented-Language
I have compiled some of the common mistakes that beginners make.
52
Upvotes
3
u/R3D3-1 Oct 18 '21 edited Oct 18 '21
But it has.
The only unusual thing about Python's ternary expressions is that the expressions, which are not skipped, are not evaluated left-to-right. An aspect I personally dislike; I'd much prefer if python had opted for left-to-right expressions, e.g.
More verbose, but it would preserve consistency between control flow statements and the corresponding relations. Particularly obnoxious is to remember the order of item produced by
partly due to flipping back and forth the ordering.
The given examples actually even fail the specification; The first probably has a typo (it should probably be
l1in the argument list), otherwise it would have a name error, but even then both examples modify the existing list by side-effect.Missed opportunity to write it as