Ask Your Question
2

In what way can I mention function names that are saved in a variable as a string without executing them?

asked 2021-08-29 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-03 10:00:00 +0000

nofretete gravatar image

You can mention the function names that are saved in a variable as a string by simply using the variable name without parentheses. This will not execute the function but will only refer to it as a string value. For example, if you have a function named "myfunction" that is saved in a variable "funcname" as a string, you can mention it like this:

func_name = "my_function"

print(func_name)   # Output: my_function

This will print the string value of the variable "funcname" which is "myfunction". It will not execute the function.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-29 11:00:00 +0000

Seen: 10 times

Last updated: Jul 03 '22