About 536,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. 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.

  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. 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 …

  6. How to Call Functions by String Name in Python

    This guide explores various techniques for calling a function using a string name in Python, emphasizing safe and recommended practices. We'll cover techniques using getattr(), …

  7. 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 …

  8. Call a Function by a String name in Python | by Glasshost

    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 ()` …

  9. 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, …

  10. Call Python Function by String Name - Fedingo

    Mar 22, 2022 · First, if the function to be called is in the same module from where you are calling it, then you can use locals () or globals () to call the function by its string. locals () contains the …

Refresh