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.
*, 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
greetfunction instead ofgreetingsmodule - Call the
greet("Jeff")function
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules