I’m new to python from a java background. Python is so easy when you are writing new code or are reading code you wrote in the last hour (e.g. during an interview).
Reading some code I wrote last week in a Colab notebook for a class notebook using some API that I’m learning (e.g. Word2Vec), it’s not so easy. I don’t know what operations I can perform on this variable I added but didn’t name with enough information to trivially determine its type.
Java is so explicit with type declarations it makes you cry, but I’m seeing the dark side of dynamic typing.
One possible solution is to use type hints anywhere the type info is welcome (subjective I know). But is there any kind of best practice which maybe says that you should not do it to the point it just crowds your code and makes you hate yourself the way Java does?
(EDIT: yes I know modern java has var but the reality is it’s in very few codebases because of version fatigue. Same reason we don’t see much C23 or C++23)
submitted by /u/sarnobat to r/Python
[link] [comments]
Laisser un commentaire