About 380,000 results
Open links in new tab
  1. when to use functions in python and when not to ... - Stack Overflow

    Aug 12, 2018 · Functions are a way of compartmentalizing code such that it makes it both easier to read and easier to manage. In this case, there are a few concepts you must understand …

  2. python - Why do some functions have underscores - Stack Overflow

    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 …

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

  4. python - How do I call a function from another .py file ... - Stack ...

    #Import defined functions from myfun import * #Call functions Print_Text() c=Add(1,2) Solution2: if this above solution did not work for Colab. Create a foldermyfun; Inside this folder create a file …

  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 …

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

    python_file1.py x = 20 def test(): global x return x test() python_file2.py from python_file1 import * print(x) Solution 2: This solution can be useful when the variable in function 1 is not predefined.

  7. python - Using a dictionary to select function to execute - Stack …

    @Ben Believe me, I am very aware of that, I have 8 years providing software solutions, this is the first time I use Python and I wish I could use many security features from other languages, …

  8. python - What does ** (double star/asterisk) and * (star/asterisk) …

    Aug 31, 2008 · BONUS: From python 3.8 onward, one can use / in function definition to enforce positional only parameters. In the following example, parameters a and b are positional-only , …

  9. calling a function from class in python - different way

    IMHO: object oriented programming in Python sucks quite a lot. The method dispatching is not very straightforward, you need to know about bound/unbound instance/class (and static!) …

  10. python - How do I forward-declare a function to avoid …

    Python's functions are anonymous just like values are anonymous, yet they can be bound to a name. In the above code, foo() does not call a function with the name foo, it calls a function …

Refresh