determine what result to return is not pure function of courseall the other types of callables we discuss also allow reliance on state in various ways the author of this report has long pondered whether he could use some dark magic within python explicitly to declare function as pure--say by decorating it with hypothetical @purefunction decorator that would raise an exception if the function can have side effects--but consensus seems to be that it would be impossible to guard against every edge case in python' internal machinery the advantage of pure function and side-effect-free code is that it is generally easier to debug and test callables that freely intersperse statefulness with their returned results cannot be examined independently of their running context to see how they behaveat least not entirely so for examplea unit test (using doctest or unittestor some third-party testing framework such as py test or nosemight succeed in one context but fail when identical calls are made within runningstateful program of courseat the very leastany program that does anything must have some kind of output (whether to consolea filea databaseover the networkor whateverin it to do anything usefulso side effects cannot be entirely eliminatedonly isolated to degree when thinking in functional programming terms named functions and lambdas the most obvious ways to create callables in python arein definite order of obviousnessnamed functions and lambdas the only inprinciple difference between them is simply whether they have __qualname__ attributesince both can very well be bound to one or more names in most caseslambda expressions are used within python only for callbacks and other uses where simple action is inlined into function call but as we have shown in this reportflow control in general can be incorporated into single-expression lambdas if we really want let' define simple example to illustratedef hello (name)print("hello"namehello lambda nameprint("hello"namehello ('david'hello david callables