About 615,000 results
Open links in new tab
  1. python - How do I get ("return") a result (output) from a function? How ...

    The natural, simple, direct, explicit way to get information back from a function is to return it. Broadly speaking, the purpose of a function is to compute a value, and return signifies "this is the value we …

  2. python - What is the purpose of the return statement? How is it ...

    The return statement causes your function to exit and hand back a value to its caller. The point of functions in general is to take in inputs and return something. The return statement is used when a …

  3. python: return, return None, and no return at all -- is there any ...

    Using return None This tells that the function is indeed meant to return a value for later use, and in this case it returns None. This value None can then be used elsewhere. return None is never used if …

  4. python - Return a default value if a dictionary key is not available ...

    The constructor takes a function that is called with the key and should return the value for the dictionary. This value is then stored and retrieved from the dictionary next time.

  5. python - How can I find the index for a given item in a list? - Stack ...

    It just uses the Python function array.index() and with a simple Try / Except, it returns the position of the record if it is found in the list and returns -1 if it is not found in the list (like in JavaScript with the …

  6. python - How can I get the return value of a function passed to ...

    Dec 1, 2016 · In the example code below, I'd like to get the return value of the function worker. How can I go about doing this? Where is this value stored? Example Code: import multiprocessing def …

  7. how to return values in a python dictionary - Stack Overflow

    Feb 20, 2023 · A Python dictionary is a collection of Key-Value pairs, meaning that you have several items each with an "index" or "name" (the key) and a value (anything, in your case, lists)

  8. function - Ignore python multiple return value - Stack Overflow

    Say I have a Python function that returns multiple values in a tuple: def func(): return 1, 2 Is there a nice way to ignore one of the results rather than just assigning to a temporary variabl...

  9. Python returns MagicMock object instead of return_value

    Jul 5, 2016 · When testing, A() returns the return_value from mock_A (a regular MagicMock, as you haven't specified anything else), which is not an instance of the class A. You need to set that …

  10. How to get the return value from a thread? - Stack Overflow

    Mar 18, 2023 · Comfortable return value & exception handling of a threaded function is a frequent "Pythonic" need and should indeed already be offered by the threading module - possibly directly in …