The AnyStr type variable

1 · Guido van Rossum · May 17, 2016, 4:53 p.m.
The AnyStr type variable I was drafting a blog post on how to add type annotations for the new __fspath__()  protocol (PEP 519) when I realized that I should write a separate post about AnyStr . So here it is.A simple function on stringsLet’s write a function that surrounds a string in parentheses. We’ll put it in a file named demo.py :def parenthesize(s):    return '(' + s + ')'It works, too:>>> from demo import parenthesize>>> print(parenthesize('hola'))(hola)Of course, if you pass it somethin...