POST 1 of 5 MorningPythonConcept
Python isn't typeless — you just can't see them
Tell a Python beginner that Python has types and they'll usually look at you funny. 'Python is typeless, right? You just write x = 5 and it works.' That's the most expensive misconception in the language. Python is dynamically typed, not typeless. There is a massive difference. Every value in Python has a type. The integer 5 has type int. The string 'hello' has type str. What's flexible is the *variable*, not the value. The variable is just a label. You can re-point the label at a different value, and the value's type is whatever the new value's type is. x = 10 # x points at an int x = 'ten' # now x points at a str x = [1, 2] # now x points at a list The int 10 didn't 'change type' to a string. The variable just stopped pointing at 10 and started pointing at 'ten'. The values themselves are typed and immutable about it. Why this matters in practice. When you see a function in someone else's code, you have no idea what type the variables are. Production bugs love this. You pass a string where the function expected a list, and the error doesn't surface for three function calls — buried under .append() failing on a string. The fix isn't to abandon dynamic typing. It's to *annotate* what you mean — type hints (we cover them on Day 13). Hints don't change runtime behaviour. They give you, your IDE, and tools like mypy a way to catch the bugs before the code runs. Dynamic typing isn't 'no types'. It's 'types you can't see unless you write them down'. Write them down.
#AI#MachineLearning#Python#100DaysOfCode#BuildInPublic#PythonTypes#Python3