Statements and Identifiers
Learn about the different statements we have not yet covered and be introduced to the concept of identifiers in Python.
We'll cover the following
Description of some Python statements
This section describes the Python statements we have not covered so far, or that have more options than have previously been covered. Let’s take a look at them:
1. import
statement:
import module
will import all the names from the specifiedmodule
, but every use of a name must be prefixed bymodule
and a dot (.
). This is to prevent problems when the same name is imported from more than one module.from module import names
will import the given names, which do not need to be prefixed bymodule
and a dot (.
). Ifnames
is replaced by an asterisk (*
), that means to import all names.import module as name
will import all the names frommodule
, but every use of a name must be prefixed byname
and a dot (.
).from module import name1 as name2
importsname1
but renames it toname2
.
Get hands-on with 1400+ tech skills courses.