2- how python runs programs Flashcards
What really happens when a python program runs?
first the source is complied into bytecode, then this is routed to the virtual machine
The compiler creates a new file, what is the extension?
.pyc
In python 3.2 and later, the bytecode files are saved in what directory?
__pychache__
what does Python check to see if the bytecode files need to be updated?
The last modified timestamps of both the source and the byte code files. It also check the version of Python from the byte code.
can Python run a program with only bytecode files ( no source)
yes
What is a namespace?
package of variable names
what is a module
it’s just a .py file.
When a module is imported, what is the last thing that is done?
it’s run.
what are names within packages called?
attributes. These are simply variable names for specific objects.
what is the difference between import an from
from does one extra thing. From copies a modules attributes, so that they become variables in the recipient.
what is the syntax to use from in a file called test1 and a attribute called blaster
from test1 import blaster
what function prints an imported module’s names in a list
dir
What is the python conceptual hierarchy?
Programs are composed of modules. Modules contain Statements. Statements contain expressions. Expression create and process objects.