| how can Python be strongly typed if it doesn't enforce types for declared arguments? What is the value of this supposedly "strongly typed" Python's type system? class Object: pass
def f(arg:int): print("type of arg = ", str(type(arg)))
f(1)f(666.0) f("kek") f(Object()) type of arg = <class 'int'> type of arg = <class 'float'> type of arg = <class 'str'> type of arg = <class '__main__.Object'> and not a single error/warning thrown |
But for a demonstration (compare to Perl) try this in your Python REPL:
Does it work? Probably not unless you futzed with the language implementation. In Perl it does, though. So to the extent that "strong typing" means anything, Perl is "weakly typed", Python is "strongly typed", and both are dynamically typed. It's an orthogonal characteristic of the type system and language from when type checking occurs.----------
EDIT: BTW, formatting code blocks on HN is really easy. Prefix each line of code with two space characters.
The result is much cleaner than your comment: No extra newlines needed, more compact, easier for most people to read.