About 458,000 results
Open links in new tab
  1. Python - Passing a function into another function - Stack Overflow

    functions are first-class objects in python. you can pass them around, include them in dicts, lists, etc. Just don't include the parenthesis after the function name. Example, for a function named myfunction: myfunction means the function itself, myfunction() means to call the function and get its return value instead. –

  2. How to call a function within a function from another function in …

    Jan 1, 2018 · You can not, since a function is procedural, you define the function when you a specific func2() when you call func1(). If you call func1() multiple times, you will define several func2s. Furthermore since it is procedural, it is possible that func2 is never declared (in an if statement). Here you do not return the function, so unless with ...

  3. python - How do you call a function in a function ... - Stack Overflow

    I have a function and I'm making another one in which I need to call the first function. I don't have experience in Python, but I know that in languages like MATLAB it's possible as long as they're in the same directory. A basic example: def square(x): square = x * x (and saved) Now in my new function I want to use the function square I tried:

  4. python - Call a function defined in another function - Stack Overflow

    Dec 13, 2011 · @Kazark Thank you. I wasn't aware of this impression given by a lack of explanation. On the contrary, I thought that it could be lighter for a reader not to have evident comments concerning so easy to understand codes. - "hack" appears to me as an excessive word for my codes - I didn't try to give a better answer than other ones, I showed other ways that may give to OP additional ideas and ...

  5. python - How to call a script from another script? - Stack Overflow

    Running Python as a subprocess of Python is almost never the correct solution. If you do go with a subprocess, you should avoid Popen unless the higher-level functions really cannot do what you want. In this case, check_call or run would do everything you need and more, with substantially less plumbing in your own code. –

  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. Call a function from within another function in Python

    Jul 24, 2012 · I'm starting to learn Python, but I'm having an issue with my code and was hoping someone could help. I have two functions, and I would like to call one function from the other. When I simply tried

  8. python - How can I call a function within a class? - Stack Overflow

    Python, Call a class function within another class. 0. Call a function from outside a class - Python. 1 ...

  9. Passing functions with arguments to another function in Python?

    Assume you have a function add(x, y) and you want to pass add(3, y) to some other function as parameter such that the other function decides the value for y. Use lambda # generic function takes op and its argument def runOp(op, val): return op(val) # declare full function def add(x, y): return x+y # run example def main(): f = lambda y: add(3 ...

  10. Run a Python script from another Python script, passing in …

    Mar 27, 2019 · I want to run a Python script from another Python script. I want to pass variables like I would using the command line. For example, I would run my first script that would iterate through a list of values (0,1,2,3) and pass those to the …

Refresh