By industry leaders and academic researchers alike, Python is touted as one oftheabsolutebestlanguagesfor novice programmers.
And theyre not wrong but that doesnt mean that it doesnt confuse the shit out of programming newbies anyway.
Takedynamic typingas an example.

This makes everything go faster!
Then you mess it up on one single line yes, one!
and your whole project crashes before its finished running.
To be fair,many other languagesuse dynamic typing.
But in the case of Python, this is only the beginning of the shit-list.
Reading code gets messy with implicitly declared variables
40% off TNW Conference!
Thats where it got problematic…
The whole code was littered with variables that were declared nowhere.
Im hardly alone with this experience.
TheZen of Pythonclearly says explicit is better than implicit.
Like so:
Thats a silly example, I know.
Now consider this:
So far, so good.
But what happens if you execute it again?
This works because lists, unlike integers, aremutable types.
One could also say, Python plus optional arguments plus mutable objects is insanity.
If you do object-oriented programming that is almost everyone classes are everywhere in your Python code.
And one of the most useful features of classes of all time is… (drumroll)… inheritance.
Like this:
This isnt a particularly brainy example, so dont copy it into your code projects.
This works:
And what happened when you were little and mommy dyed her hair?
Your hair didnt change, right?
This happens because of PythonsMethod Resolution Order.
Basically, the child classes inherit everything the parents have, as long as its not stated otherwise.
Scopes go inside out sometimes
This next one Ive stumbled over so many times.
In Python, if youre defining a variable inside a function, this variable wont work outside the function.
But what about the other way around?
It took me a while to get to the root of the problem.
Like if Albert dreams about turning the trees orange that doesnt make the trees orange of course.
Luckily, theres asimple solutionto this problem.
Just slap a global before x!
So if you thought scopes only shield variables inside functions from the outside world, think again.
Consider this:
This loop doesnt work because it deletes an element of the list every so often.
The lists end therefore shifts forward.
Then its impossible to arrive at element number 10 because its no longer there!
But theres a much better solution:
Just one line of code!
Note that weve already used Pythonslist comprehensionin the broken example above, to invoke the list.
Its the expression in the square brackets [], and is basically a short form for loops.
List comprehensions are oftena little bit fasterthan regular loops, which is cool if youre handling large datasets.
Unlike some of the phenomena described above, this isnt a case of Python madness.
Even if beginners may stumble over this at first, this is Python genius.
This has gottena lot better now.
TheNumpy package, for example, is incredibly fast at handling lists, matrices, and the like.
Multiprocessinghas gotten much easier with Python, too.
Packages like Pytorch and Tensorflow make thisdead easy, and other languages are struggling to keep up.
However, the fact that Python has become better over the years doesnt guarantee a rosy future.
Python still isnt idiot-proof.
Use it with caution.
This article was originally published on Medium.
you’re able to read ithere.