About 380,000 results
Open links in new tab
  1. Simplest async/await example possible in Python

    Jun 8, 2018 · In case 2, we added async to the normal function. However the event loop will run it without interruption. Why? Because we didn't say where the loop is allowed to interrupt your function to run another task. In case 3, we told the event loop exactly where to interrupt the function to run another task. Where exactly? Right here! await asyncio ...

  2. Basic explanation of python functions - Stack Overflow

    Sep 5, 2015 · For example, consider the function f(x, y) = x - y. If this function is called as z = f(3, 4) then the argument by the name of x will receive the value 3 and y will be 4, to return -1. If you reverse the arguments in the call, then you'd have x=4 and y=3 and it'd return 1 instead. The same is true of the arguments in the function you've provided.

  3. Caesar Cipher Function in Python - Stack Overflow

    Feb 23, 2015 · The Python Standard Library defines a function maketrans() and a method translate that operates on strings. The function maketrans() creates translation tables that can be used with the translate method to change one set of characters to another more efficiently. (Quoted from The Python Standard Library by Example).

  4. How to send an email with Python? - Stack Overflow

    I wrote a simple function send_email() for email sending with smtplib and email packages (link to my article). It additionally uses dotenv package to loads the sender email and password (please don't keep secrets in the code!).

  5. How do I parallelize a simple Python loop? - Stack Overflow

    Mar 20, 2012 · This runs Before Loop! function finished for argument=2 and other_argument=1 function finished for argument=3 and other_argument=1 function finished for argument=1 and other_argument=1 function finished for argument=4 and other_argument=1 This runs After Loop! 3. Run multiple loops in parallel and wait for finish

  6. Simple login function in Python - Stack Overflow

    Simple login function in Python. Ask Question Asked 10 years, 2 months ago. Modified 5 years, 1 month ago. ...

  7. Simple Python Function - Stack Overflow

    Very simple python function. 0. A small function in python. 4. Function in python. 0. writing simple ...

  8. How do I measure elapsed time in Python? - Stack Overflow

    % python -mtimeit -s'import test' 'test.foo()' 1000000 loops, best of 3: 0.254 usec per loop Do not try to use time.time or time.clock (naively) to compare the speed of functions. They can give misleading results. PS. Do not put print statements in a function you wish to time; otherwise the time measured will depend on the speed of the terminal.

  9. python - How can I write a simple callback function ... - Stack …

    The fact that you did callback(1, 2) first will call that function, thereby printing Sum = 3, and then main() gets called with the result of the callback function, which is printing the second line. Since callback returns no explicit value, it is returned as None. Thus, your code is equivalent to. callback(1, 2) main()

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

    Jan 30, 2009 · Next we need a function to terminate the main() from the child thread: def quit_function(fn_name): # print to stderr, unbuffered in Python 2. print('{0} took too long'.format(fn_name), file=sys.stderr) sys.stderr.flush() # Python 3 stderr is likely buffered. thread.interrupt_main() # raises KeyboardInterrupt And here is the decorator itself: