Editor settings

General settings

Save settings

Learn to program with Python

Importing specific values #

To import specific values from a module, we use the from keyword followed by the module name, then the import keyword, and finally the specific values we want to import. Here's an example:

from module_name import value_name

In this case, we are importing only the value_name from the module module_name module, instead of the entire module. We can then use the value_name in our code.

We could also import all values by using the wildcard *, like so: from module_name import * . However, this is generally not recommended, as it can lead to name clashes and make the code harder to read and maintain, since we won't know from which module are the values coming from.

Exercise #

Update the import statement to import the function greet instead of importing the greetings module.

Tests #

  • Import greet function instead of greetings module
  • Call the greet("Jeff") function
Output will be displayed here