It's called a type hint.
Python is a language in which types are determined dynamically. That means you don't know what type it is until you do it.
This means, in other words, that an error by type cannot be known unless it is runtime (running).
def hab(arg1, arg2):
return arg1 /arg2
When a simple division function exists, as shown in
Calling with hab(10,2) will work as expected, but... Calling hab ("aaaa", "bbbb") will result in an error.
At this time, you can write code that can be explicitly typed as below to prevent errors and is easy to maintain.
def hab(arg1, arg2: int) -> int:
return arg1 /arg2
One more thing is that the performance of hab ("aaaa", "bbbb") is not preventive because it is not compulsory. It's just a hint.
535 Unable to install versioned in Google Colab
624 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
536 PHP ssh2_scp_send fails to send files as intended
536 Understanding How to Configure Google API Key
541 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.