⊗pyPmMdMA 85 of 128 menu

Importing the Entire Contents of a File into Python

To import the entire contents of a file, you can use the special command *:

from module import *

The convenience of this method of import is that all the resulting functions can be written without the module name, which significantly improves the readability of the code and shortens it.

Let's import all functions from the lib module and try to access func3:

from lib import * func3()

After executing the code, the result of func3 will be displayed:

3

If you only need to import part of a module, you should put an underscore before the name of the unnecessary function:

... def _func3(): print(3)

Now let's try calling func3:

func3()

The following error will be displayed in the console:

NameError: name 'func3' is not defined. Did you mean: 'func1'?

This function can only be imported into the working file directly by specifying it after the import command:

from lib import _func3 _func3() # 3

Import all the functions from the custom_math module you created in the previous lesson.

Modify the previous task so that the get_divide function cannot be imported along with the entire contents of the module.

Make the user's password and email from the user module unavailable for import.

enru