appendix python merely modifying this copy of the localsnot the local variables themselves here is one workarounddef foo()_locals locals(exec(" ",globals(),_localsa _locals[' 'extract the set variable print(aas general ruledon' expect python to support the same degree of "magicthat was possible using exec()eval()and execfile(in python in factexecfile(is gone entirely (you can emulate its functionality by passing an open file-like object to exec()use of iterators and views python makes much greater use of iterators and generators than python built-in functions such as zip()map()and range(that used to return lists now return iterables if you need to make list from the resultuse the list(function python takes slightly different approach to extracting key and value information from dictionary in python you could use methods such as keys() values()or items(to obtain lists of keysvaluesor key/value pairsrespectively in python these methods return so-called view objects for examples 'goog' 'aapl' 'ibm' keys( values( these objects support iteration so if you want to view the contentsyou can use for loop for examplefor in kprint(xgoog aapl ibm view objects are always tied back to the dictionary from which they were created subtle aspect of this is that if the underlying dictionary changesthe items produced by the view change as well for examples['acme' for in kprint(xgoog aapl ibm acme should it be necessary to build list of dictionary keys or valuessimply use the list(function--for examplelist( keys() lib fl ff