Developing for tomorrow, one dream at a time
Now for some fun. Everything in Python, from Functions, Classes and strings are objects in Python. This means, a few fun things:
With web applications, writing functions with as little context, and side-effects as possible is the smarter way to go, as running multiple instances of a python process can lead to concurrency problems, as an object may be deleted before another object goes to read it. You know.. chicken and egg syndrome. Isolating functions with context data, from functions with logic can have the following benefits:
def function_name():
print("My function")
function_name()
The above code snippet creates a function and calls it. So in Python land, indentation is master. When you define your function name, end that line with a colon (:) and then the next lines that define the function need to be indented. Once the function code has ended remove the indentation and continue.