like map calls and list comprehension expressions--tools we met in earlier and will revisit in this and the next import sys showall lambda xlist(map(sys stdout writex) xmust use list showall(['spam\ ''toast\ ''eggs\ '] xcan use print spam toast eggs showall lambda [sys stdout write(linefor line in xt showall(('bright\ ''side\ ''of\ ''life\ ')bright side of life showall lambda [print(lineend=''for line in xsame only showall lambda xprint(*xsep=''end=''same only there is limit to emulating statements with expressionsyou can' directly achieve an assignment statement' effectfor instancethough tools like the setattr built-inthe __dict__ of namespacesand methods that change mutable objects in place can sometimes stand inand functional programming techniques can take you deep into the dark realm of convoluted expression now that 've shown you these tricksi am required to ask you to please only use them as last resort without due carethey can lead to unreadable ( obfuscatedpython code in generalsimple is better than complexexplicit is better than implicitand full statements are better than arcane expressions that' why lambda is limited to expressions if you have larger logic to codeuse deflambda is for small pieces of inline code on the other handyou may find these techniques useful in moderation scopeslambdas can be nested too lambdas are the main beneficiaries of nested function scope lookup (the in the legb scope rule we studied in as reviewin the following the lambda appears inside def--the typical case--and so can access the value that the name had in the enclosing function' scope at the time that the enclosing function was calleddef action( )return (lambda yx ymake and return functionremember act action( act at ca act( call what action returned what wasn' illustrated in the prior discussion of nested function scopes is that lambda also has access to the names in any enclosing lambda this case is somewhat obscurebut imagine if we recoded the prior def with lambda advanced function topics