For #1,
from typing import List
def average(L : list[float]) -> float:
print("HELLO")
Normal operation. For #2
from typing import List
def average(L : Gist[float]) -> float:
print("HELLO")
If
Traceback (most recent call last):
File "<pyshell#86>", line 1, in <module>
def average(L : Gist[float]) -> float:
NameError: name 'Gist' is not defined
1. I print out a message, but what I'm curious about is that if the type notation is not set according to the type, an error message appears after L:
, and if the type is adjusted and the value is put in the factor, does it not send an error message?
Question number two
from typing import List
def average(L : list[float]) -> float:
print("HELLO")
from typing import List
def average(L : List[float]) -> float:
print("HELLO")
1. What do you get from import list
in these two codes?
2. Do I have to write L:list
and L:list
separately?
Python was created in a dynamic language, so there was no type designation in the beginning.
However, as the version went up, the type-hinting function was added, and as it was added, it was developed, so there were some imperfections. The list of typing, Dict, etc. are made and developed in that way. It's a bit vague to import the type and use type.
Types such as list and dict are included in the official Python after typing. Functionally, it tells the type of variable, so it seems to be used for static analysis. The restriction is smaller than other Kangta language.
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
610 Uncaught (inpromise) Error on Electron: An object could not be cloned
572 Understanding How to Configure Google API Key
599 GDB gets version error when attempting to debug with the Presense SDK (IDE)
567 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.