About 1,330,000 results
Open links in new tab
  1. python - How can I use a global variable in a function? - Stack …

    Jul 11, 2016 · In Python, the module is the natural place for global data: Each module has its own private symbol table, which is used as the global symbol table by all functions defined in the …

  2. python - How do I call a function from another .py file? - Stack …

    function(a, b) Note that file is one of Python's core modules, so I suggest you change the filename of file.py to something else. Note that if you're trying to import functions from a.py to a file …

  3. python - Why do some functions have underscores "__" before …

    May 24, 2024 · In Python, the use of an underscore in a function name indicates that the function is intended for internal use and should not be called directly by users. It is a convention used …

  4. How can I use a DLL file from Python? - Stack Overflow

    Oct 31, 2008 · 238 What is the easiest way to use a DLL file from within Python? Specifically, how can this be done without writing any additional wrapper C++ code to expose the functionality to …

  5. In Python, when should I use a function instead of a method?

    The Zen of Python states that there should only be one way to do things- yet frequently I run into the problem of deciding when to use a function versus when to use a method. Let's take a trivial

  6. python - How do I get ("return") a result (output) from a function?

    We can make a tuple right on the return line; or we can use a dictionary, a namedtuple (Python 2.6+), a types.simpleNamespace (Python 3.3+), a dataclass (Python 3.7+), or some other …

  7. When should I use a class and when should I use a function?

    Jul 4, 2012 · Python isn't like that. It's perfectly OK - in fact recommended - to define functions standalone, and related functions can be grouped together in modules. As others have stated, …

  8. python - Why use lambda functions? - Stack Overflow

    A more interesting use would be to dynamically construct a python function to evaluate a mathematical expression that isn't known until run time (user input). Once created, that …

  9. How to import functions from other projects in Python?

    Ideally both projects will be an installable python package, replete with __init__.py and setup.py. They could then be installed with python setup.py install or similar. If that is not possible, don't …

  10. python - How to use a variable defined inside one function from …

    The simplest option is to use a global variable. Then create a function that gets the current word. Notice that to read global variables inside a function, you do not need to use the global …