РА
Size: a a a
РА
РА
E
РА
͏
͏
РА
͏
BQ
͏
͏
͏
͏
͏
M
V
# lib.pyC виду ничего не изменилось. Как понять, что тайп хинты что-то изменили?
def foo1(x): # old style, no type hints
return x*x
def foo2(x: int) -> int: # type hints
return x*x
# test.py
from lib import foo1, foo2
for f in (foo1, foo2):
try:
print(f('asd'))
except Exception as e:
print(e)
$ python3 test.py
can't multiply sequence by non-int of type 'str'
can't multiply sequence by non-int of type 'str'
DC
# lib.pyC виду ничего не изменилось. Как понять, что тайп хинты что-то изменили?
def foo1(x): # old style, no type hints
return x*x
def foo2(x: int) -> int: # type hints
return x*x
# test.py
from lib import foo1, foo2
for f in (foo1, foo2):
try:
print(f('asd'))
except Exception as e:
print(e)
$ python3 test.py
can't multiply sequence by non-int of type 'str'
can't multiply sequence by non-int of type 'str'
DC