Linked Questions
13 questions linked to/from Python function pointer
-1
votes
3
answers
7k
views
How to call a method whose name is stored in a variable [duplicate]
In the following code how to make the unicode data callable.The error that i get is //TypeError: 'unicode' object is not callable
def test(test_config):
for i in test_config:
print i....
0
votes
5
answers
365
views
Calling a function from a set variable? [duplicate]
Im writing a python script and what I would like to do is capture the input into a variable and then use that to call a function with that name. Here is an example:
def test():
print "You want to ...
0
votes
2
answers
173
views
dynamic execute a function by a string like 'module.function' [duplicate]
if I have a string like 'module.function', How can I execute function just by one step?
likesomefunction('os.error','args')
1
vote
1
answer
70
views
Get the right Python object according to a setting or user input [duplicate]
I have two inherited classes in a module shape.py :
class Shape(object):
class Triangle(Shape):
class Square(Shape):
In my main code I want to instantiate a Shape but I don't know what kind of ...
0
votes
0
answers
36
views
Python: how to get a function based on whether it matches an assigned string to it [duplicate]
I have a facebook messenger chatbot I programmed in python. There are a few dozen commands it handles, mostly via a ton of if/then statements as follows
if state == "state1":
if "command1" in ...
2
votes
4
answers
3k
views
Python design pattern to implement different variations of a function
I have a generic smoothing function, and based on a configuration file (yaml which will be loaded as a dictionary), different implementation (boxcar or gaussian) will be called. These implementations ...
0
votes
3
answers
2k
views
Call a built-in function with a string in Python
I've referred to the following threads and I don't think that this post is a duplicate of any of them:
Calling a function of a module by using its name (a string)
Python Call Function from String
Use ...
1
vote
3
answers
4k
views
Python function pointer with different argument size
My question is some how related to this question, I have a dictionary of functions with a different number of arguments, how can I call them in an automatic way?
funcdict = {
'mypackage.mymodule1....
1
vote
2
answers
133
views
how a function in python is getting called by just typing the name of function and not using brackets
First of all to find "lcm" of two numbers I made a function lcm(a, b). Then I thought of finding "hcf" too so I made a decorator decor and defined a function hcf(a, b) in it. And then I returned this ...
-1
votes
3
answers
391
views
C++, efficient way to call many possible functions from user
I'm relatively new to c++, mostly worked with python.
I have a scenario where a user(me) uses a GUI to send commands to a microcontroller via serial, and then the microcontroller processes them.
Right ...
0
votes
2
answers
131
views
How do you call a function defined in the current function by its name (a string)
How to call a function when it's name is stored in a string, has already been answered.
What I want to know is how do I do this if the function I'm wanting to call is defined in my local scope.
This ...
-2
votes
3
answers
68
views
How can I use a variable when calling a function? [duplicate]
Basically, I have a lot of functions that have a similar name (p1(), p2(), p3(), ..., p20()) and I don't want to call them all by hand. I want to do something like this:
for i in range(1, 21):
p{...
0
votes
1
answer
32
views
How can I remove a string's parentheses so it can be used in functions?
If I make a function call check('list') and in the function that I'm defining, which is called check, I want to use if isinstance(value, x): where x is the argument of check, currently 'list' but it ...