renames module or tool your code uses extensivelyor provides new alternative you' rather use insteadyou can simply rename it to its prior name on import to avoid breaking your codeimport newname as oldname from library import newname as oldname and keep happily using oldname until you have time to update all your code for examplethis approach can address some library changes ( ' tkinter versus ' tkinter)though they're often substantially more than just new nameexamplemodules are objects because modules expose most of their interesting properties as built-in attributesit' easy to write programs that manage other programs we usually call such manager programs metaprograms because they work on top of other systems this is also referred to as introspectionbecause programs can see and process object internals introspection is somewhat advanced featurebut it can be useful for building programming tools for instanceto get to an attribute called name in module called mwe can use attribute qualification or index the module' attribute dictionaryexposed in the built-in __dict__ attribute we met in python also exports the list of all loaded modules as the sys modules dictionary and provides built-in called getattr that lets us fetch attributes from their string names--it' like saying object attrbut attr is an expression that yields string at runtime because of thatall the following expressions reach the same attribute and object: name __dict__['name'sys modules[' 'name getattr( 'name'qualify object by attribute index namespace dictionary manually index loaded-modules table manually call built-in fetch function by exposing module internals like thispython helps you build programs about programs for examplehere is module named mydir py that puts these ideas to work to implement customized version of the built-in dir function it defines and exports function called listingwhich takes module object as an argument and prints formatted listing of the module' namespace sorted by name as we saw briefly in "other ways to access globalsin because function can access its enclosing module by going through the sys modules table like thisit can also be used to emulate the effect of the global statement for instancethe effect of global xx= can be simulated (albeit with much more typing!by saying this inside functionimport sysglob=sys modules[__name__]glob = remembereach module gets __name__ attribute for freeit' visible as global name inside the functions within the module this trick provides another way to change both local and global variables of the same name inside function examplemodules are objects