pattern matching to select subset of names (though you could with more work and loop through module' __dict__discussed aheadand that' it--modules really are simple to use to give you better understanding of what really happens when you define and use modulesthoughlet' move on to look at some of their properties in more detail in python xthe from statement form described here can be used only at the top level of module filenot within function python allows it to be used within functionbut issues warning anyhow it' rare to see this statement used inside function in practicewhen presentit makes it impossible for python to detect variables staticallybefore the function runs best practice in all pythons recommends listing all your imports at the top of module fileit' not requiredbut makes them easier to spot imports happen only once one of the most common questions people seem to ask when they start using modules is"why won' my imports keep working?they often report that the first import works finebut later imports during an interactive session (or program runseem to have no effect in factthey're not supposed to this section explains why modules are loaded and run on the first import or fromand only the first this is on purpose--because importing is an expensive operationby default python does it just once per fileper process later import operations simply fetch the already loaded module object initialization code as one consequencebecause top-level code in module file is usually executed only onceyou can use it to initialize variables consider the file simple pyfor exampleprint('hello'spam initialize variable in this examplethe print and statements run the first time the module is importedand the variable spam is initialized at import timepython import simple hello simple spam first importloads and runs file' code assignment makes an attribute second and later imports don' rerun the module' codethey just fetch the already created module object from python' internal modules table thusthe variable spam is not reinitialized module coding basics