python - x has type function but calling x gives a type error Python3 -
i have following python statement
x = lambda :8() checking type of x returns following
<class 'function'> but doing this
x() typeerror: 'int' object not callable i can solve putting parenthesis around lambda so
x = (lambda :8)() but wondering going on.
the problem not lie calling x, trying call 8 8(). calling integer raises error because instances of int not callable.
i can solve putting parenthesis around lambda so
what doing x = (lambda :8)() construct anonymous function returns number 8, call it, , assign name x return value.
>>> x = (lambda :8)() >>> x 8 however, x() still raise error because again it's trying call integer.
>>> x() traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: 'int' object not callable
Comments
Post a Comment