Statements and Identifiers

Learn about the different statements we have not yet covered and be introduced to the concept of identifiers in Python.

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 specified module, but every use of a name must be prefixed by module 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 by module and a dot (.). If names is replaced by an asterisk (*), that means to import all names.
  • import module as name will import all the names from module, but every use of a name must be prefixed by name and a dot (.).
  • from module import name1 as name2 imports name1 but renames it to name2.

Get hands-on with 1200+ tech skills courses.