A callable object is an object which also can act as a function. Some languages allow arrays, hash tables or strings to be functions.
Questions tagged [callable-object]
67 questions
1
vote
1 answer
How to `use` variables inside a closure created with `Closure::fromCallback()`?
Does PHP support useing a local variable inside the scope of a Closure even when this one is created via Closure::fromCallable() ?
Usually I'd do
$value = 'foobar';
$callback = function() use (&$value) {
$value .= ' string';
return…

Kamafeather
- 8,663
- 14
- 69
- 99
1
vote
0 answers
Error str not callable
Here is a sample of code (python 3.6):
n = 2
x = 2**n
Q = str(x)
print(q)
This yields an error "str object is not callable". But I didn't understand why? I am working with much larger numbers (integers), and I need to convert them to a string…

Barry Barron
- 45
- 5
1
vote
1 answer
Do the STL concepts cover all of the argument requirements for STL algorithms?
When looking at the template names of some of the algorithms,
I see that the name corresponds to a library concept.
Take std::mismatch for example.
template< class InputIt1, class InputIt2, class BinaryPredicate…

Trevor Hickey
- 36,288
- 32
- 162
- 271
1
vote
1 answer
'numpy.ndarray' object is not callable when using a CALLABLE function in minimization
I keep getting the numpy.ndarray object is not callable error. I know that this mistake happens because one uses an np.array instead of a function. The problem in my code, is that I am indeed using a function to run the minimize python…

k1000x
- 65
- 10
1
vote
1 answer
trouble with sympy solve with mathematical equation (python)
I have 8 lists of variables (each identical size). For each element of the list I wish to create a new list that is the result of a mathematical solution involving the variables.
Here is my code using Sympy:
from sympy.solvers import solve
from…

AIREL
- 61
- 1
- 6
0
votes
1 answer
Callable argument has unused name
Is there any reason the parameter name inside a function type exists?
function greeter(fn: (a: string) => void) {
fn("Hello, World");
}
In the above example (from the docs) why is a needed?

OrenIshShalom
- 5,974
- 9
- 37
- 87
0
votes
1 answer
Apply Callable to NDArray
I am new to Python and I have done a fair share of just trying things to see if it works. In this case, when I apply a Callable to an NDArray, I get a result, just not what I expected.
from typing import Callable
from typing import Tuple
import…

Little Endian
- 784
- 8
- 19
0
votes
1 answer
Exception Value: 'CustomUser' object is not callable | CustomUserModel
I am trying to create a custom user model. The model is working fine in command prompt and I am able to login to admin panel as well. I can access Login page as well. But when I try to access the SignUp page Is is showing me the following…
0
votes
1 answer
How to accept only callable objects in templates except pointer to data members?
I want to create a templated function which accepts and invokes a callable object(except pointer to data members) with arguments to pass to it.
I want the template to only accept the following types:-
Pointers to functions
Pointers to member…

Tharani B
- 21
- 1
0
votes
1 answer
Difference between Callable and FunctionType
I am trying to properly type hint my code and encountered both Callable and FunctionType
from typing import Callable
def my_func() -> Callable:
f = lambda: _
return f
result = my_func()
type(result) #
isinstance(result,…

GopherM
- 352
- 2
- 8
0
votes
0 answers
What are the different types of callables in Python?
I used to think functions, classes, and methods as the only callables in Python, but recently learnt that instances can also be made callable. This left me wondering if I'm done with this list or are there more types of callables I'm yet to…

Neo Anderson
- 35
- 1
- 1
- 7
0
votes
2 answers
I work in Python and I am trying to convert a list of strings in a list of callabe functions
From something like:
strings = ["f1", "f2"]
I would like to obtain a list of functions to be called later, like:
functions = [f1, f2]
f1 an f2 are the names of 2 methods defined in a python script (not included in a class)
0
votes
1 answer
Injecting a callable object into a class as a method
It is possible to inject a function into a class like this:
class MainClass:
...
def simple_injected_func(self: MainClass, arg: str) -> None:
print(f"simple_injected_func({arg})")
MainClass.simple_injected_func =…

Hans
- 2,354
- 3
- 25
- 35
0
votes
1 answer
BeautifulSoup - TypeError: 'module' object is not callable
Can anyone explain to me why am I getting this error message? I have the exact same code in another project but after creating a new venv and install requests, bs4 and html.parser I get this message. I don't understand, at all.
import…

c0nfluks
- 53
- 5
0
votes
1 answer
getting TypeError: 'TextDetector' object is not callable
My TextDetector object is a blueprint of a class but still not able to call it.
it was working before but now it is not working. Don't know why it happened. Can anyone of you give me a reason for this TypeError?
import predict_det
#from predict_det…
user13559640