About 548,000 results
Open links in new tab
  1. python - Calling a function of a module by using its name (a string ...

    Jun 4, 2022 · How do I call a function, using a string with the function's name? For example: import foo func_name = "bar" call(foo, func_name) # calls foo.bar()

  2. Call a function by a String name – Python | GeeksforGeeks

    Apr 24, 2025 · In this article, we will see how to call a function of a module by using its name (a string) in Python. Basically, we use a function of any module as a string, let's say, we want to …

  3. Python: call a function from string name - Stack Overflow

    Oct 29, 2011 · I have a str object for example: menu = 'install'. I want to run install method from this string. For example when I call menu(some, arguments) it will call install(some, …

  4. How to Call a Function From String Name in Python | Delft Stack

    Feb 12, 2024 · Use getattr() to Call a Function From a String in Python. The getattr() function in Python is primarily used to retrieve the value of an attribute from an object. However, since …

  5. How to Call Function by String Name in Python? - Python Guides

    Apr 2, 2025 · Learn how to call a function by its string name in Python using the `globals()` or `getattr()` functions. Execute dynamically named functions efficiently.

  6. python - Call method from string - Stack Overflow

    If I have a Python class, and would like to call a function from it depending on a variable, how would I do so? I imagined following could do it: class CallMe: # Class def App(): # Method one ...

  7. Call a Function by a String name in Python | bobbyhadz

    Apr 10, 2024 · To call a function by a string name: Use the getattr() function to get the function. Call the function. If you need to call a function given a string name and the function is defined …

  8. Python Functions - Python Guides

    Call Function by String Name in Python; Conclusion. Functions are one of the most powerful features in Python, enabling code reuse, abstraction, and modularity. By mastering the …

  9. Calling Functions by Name in Python: A Comprehensive Guide

    Feb 18, 2025 · In Python, you can dynamically call a function by providing its name as a string. This technique is often used in scenarios where you don't know the exact function name …

  10. Call a Function by a String name in Python - Medium

    May 4, 2023 · Sometimes, we may need to call a function in Python whose name is only known during runtime or whose name is stored in a string. In such cases, we can use the `getattr ()` …

  11. Some results have been removed
Refresh