+ 4
def(self,function: Callable)->Tuple[float,res]: what's this ?
I saw some libraries source code in Python , it have def(self,function: Callable)->Tuple[float,res]: I don't known what's this '' Can any one Explain It to me Give any hint about It '' Project Link --- https://github.com/Alfex4936/python-bigO-calculator
5 odpowiedzi
+ 6
Python allows you to attach metadata to functions describing their parameters and return values.
def fn (self, function: Callable) -> Tuple[float,res]:
: Callable tells people who are reading the program that function should be the Callable parameter.
It is accessed as is
fn.__ annotations __ ['function']
returns typing.Callable
and has no meaning by itself.
The same with the return value of the function -> Tuple[float,res] is
fn.__ annotations __ ['return']
returns typing.Tuple[float, __main__.res]
This is a function annotation that says that the function has Callable parameter and returns a tuple with floats or res objects (but not necessarily).
https://code.sololearn.com/cHmdsW5sU23E/?ref=app
+ 7
Type Annotations in 🐍
https://link.medium.com/i9Qrb5yydkb
+ 1
Its a function definition. The first line it looks like.
+ 1
Callable is probably in exchange for ()
-> showes the return value
Look at the code and see how its used
0
Slick thanks for ans it , function : Callable means & what's ` -> ` explain this 🤥