The __init__.py file

The purpose of the _init__.py file is to specify the Python files you wish to include in your module. At a minimum, you will usually have one Python file, but you could have more or fewer depending on the complexity of the module you are developing. If you had a Python file with your code, and that file was named codexample.py, you would have to import codexample inside the __init__.py file. You will notice that you don't have to include the .py extension inside the __init__.py file.

To create the __init__.py file in Ubuntu, make sure you are in the module directory and use the following command:

sudo nano __init__.py

This will bring up the blank text editor.

For our example, the __init__.py file will contain one line that specifies the name of the file in which we will be placing the Python code for our module:

import silkworm 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.226.79