7 Things I Should’ve Learnt Much Earlier For Python Functions | by Liu Zuo Lin | Level Up Coding
My understanding of Python would have been much better if I’d somehow learnt this stuff earlier in my journey, but life is what life is, and better late than never. This is EVERYWHERE in my workplace codebase! ^ we can write functions like that because Python is dynamically typed — meaning that variable data types are determined at runtime. ^ writing the exact same function as above, but with type hints When our code base gets huge, type hinting becomes increasingly important in making our code as human-readable as possible — imagine having 10,000 functions but you need to infer the data types they take in, and their return types. Not too fun ^ ls should be a list of floats, x should be a float, and the function should return a list of floats ^ a should be a string, b should be a boolean value, and c should be a dictionary where keys are strings, and values are strings. The return value should be a dict where keys are strings, but values are integers. Note — type hints hint, not enforc
Explore this link on the map →