appear in your interface (they do at the shellbut not in idlethis convention will be followed from this point on to make larger code examples bit easier to cut and paste from an ebook or other ' assuming that by now you understand indentation rules and have had your fair share of typing python codeand some functions and classes ahead may be too large for rote input ' also listing more and more code alone or in filesand switching between these and interactive input arbitrarilywhen you see "promptthe code is typed interactivelyand can generally be cut and pasted into your python shell if you omit the "itself if this failsyou can still run by pasting line by lineor editing in file closures versus classesround to someclassesdescribed in full in part vi of this bookmay seem better at state retention like thisbecause they make their memory more explicit with attribute assignments classes also directly support additional tools that closure functions do notsuch as customization by inheritance and operator overloadingand more naturally implement multiple behaviors in the form of methods because of such distinctionsclasses may be better at implementing more complete objects stillclosure functions often provide lighter-weight and viable alternative when retaining state is the only goal they provide for per-call localized storage for data required by single nested function this is especially true when we add the nonlocal statement described ahead to allow enclosing scope state changes (in xenclosing scopes are read-onlyand so have more limited usesfrom broader perspectivethere are multiple ways for python functions to retain state between calls although the values of normal local variables go away when function returnsvalues can be retained from call to call in global variablesin class instance attributesin the enclosing scope references we've met hereand in argument defaults and function attributes some might include mutable default arguments to this list too (though others may wish they didn'twe'll preview class-based alternatives and meet function attributes later in this and get the full story on arguments and defaults in to help us judge how defaults compete on state retentionthoughthe next section gives enough of an introduction to get us started scopes and nested functions