About 237,000 results
Open links in new tab
  1. Adding a method to an existing object instance in Python

    How do I add a method to an existing object (i.e., not in the class definition) in Python? I understand that it's not generally considered good practice to do so, except in some cases.

  2. python - How to add functions - Stack Overflow

    May 6, 2016 · In your code, f needs to be a class, not a function. If you have a class, you can implement an add (self, other) method that will overload the + operator.

  3. Append values to a set in Python - Stack Overflow

    Aug 2, 2010 · I just wanted to add a quick note here. So I was looking for the fastest method among the three methods. Using the set.add () function Using the set.update () function Using …

  4. Python add to a function dynamically - Stack Overflow

    6 This answer allows you to modify the original function without creating a wrapper. I have found the following two native python types, which are useful to answer your question:

  5. python - How do I define a function with optional arguments?

    See the Python documentation for an excellent summary; the various other answers to the question make use of most of these variations. Since you always have parameters a, b, c in …

  6. How to add a timeout to a function in Python - Stack Overflow

    Feb 11, 2010 · Many attempts have been made in the past to add timeout functionality in Python such that when a specified time limit expired, waiting code could move on. Unfortunately, …

  7. python - adding to a list defined in a function - Stack Overflow

    Aug 17, 2011 · How can I create a list in a function, append to it, and then pass another value into the function to append to the list. For example: def another_function(): y = 1 list_initial(y) def

  8. python - Timeout on a function call - Stack Overflow

    Jan 30, 2009 · I'm calling a function in Python which I know may stall and force me to restart the script. How do I call the function or what do I wrap it in so that if it takes longer than 5 seconds …

  9. Python Logging (function name, file name, line number) using a …

    Jun 11, 2012 · Here is what I know: for getting function name, I can use function_name.__name__ but I don't want to use the function_name (so that I could rapidly copy and paste a generic …

  10. python - How do I add default parameters to functions when …

    Edit: I didn't know how default arguments worked in Python, but for the sake of this question, I will keep the examples above. In general it's much better to do the following: