Sturla Molden wrote: > Chris Angelico <ros...@gmail.com> wrote: > >> Uhh... if your managers and customers are stipulating non-Pythonic >> coding styles, then it's time to find new managers/customers. If >> they're not writing the code, code quality shouldn't be their concern. > > I am saying the day someone requires me to write a type hint, I will no > longer be using Python or recommending it. Python is great, but not that > great.
You probably already write type checks, only you might do it like this: def my_func(x, index=0): if not isinstance(index, int): raise TypeError("index must be an integer") do_stuff() or perhaps like this: def my_func(x, index=0): try: if index == int(index): do_stuff() except TypeError: raise else: raise TypeError("index must be an integer, not a float") And then you write tests to confirm that my_func fails correctly when given an index which is not an integer. Most of that is monkey-work, so simple that even the compiler can do it. How about writing this instead? def my_func(x, index:int=0): do_stuff() Is that really such an unspeakable burden? *Always* a burden? You cannot imagine any circumstances where you would gain some advantage by having an automated type-checker identify type-related bugs? Well okay then. Keep working the way you do right now. -- Steven -- https://mail.python.org/mailman/listinfo/python-list