Professional Documents
Culture Documents
799 PDFsam PythonNotesForProfessionals
799 PDFsam PythonNotesForProfessionals
799 PDFsam PythonNotesForProfessionals
return res
You can also sleep for a period of time before starting your execution. Note: this won't actually allow your program
to interrupt the computation happening inside the C function, but it will allow your main thread to continue after
the spawn, which is what you may expect.
def calc_fact(num):
sleep(0.001)
math.factorial(num)
def xyz():
return a, b
Code calling xyz stores result into one variable assuming xyz returns only one value:
t = xyz()
Value of t is actually a tuple (a, b) so any action on t assuming it is not a tuple may fail deep in the code with a an
unexpected error about tuples.
a, b = xyz()
Beginners will have trouble finding the reason of this message by only reading the tuple error message !
If you are used to JavaScript, variable evaluation in Python dictionaries won't be what you expect it to be. This
statement in JavaScript would result in the params object as follows:
{
"language": "en",
"my_var": "key"
}
{
"language": "en",
"bla": "key"