I came across a strange format of Python code about routine. What is the actual meaning?
def get_values() -> list:
query = "select value from table"
result = db.execute(query)
return [ value[0] for value in result ]
I think the -> list
means this routine returns data type list but I don't understand how the return (build a list)? Why it is value[0]
?
source https://stackoverflow.com/questions/72069885/how-to-interpret-this-strange-python-routine-coding-format
Comments
Post a Comment