Convert to Python Package/Module
In this section:
Overview
These two refactorings enable easy conversion between a Python module and package.
Both refactorings are performed silently.
Converting a file to a module
To convert a file to a package, follow these steps
- In the Project tool window, select the desired file.
- On the menu, choose .
The new package named by the original file is created. So doing, the content of the original file moves to the file with the name
__init__.py
.
Example
Before | After |
---|---|
Converting a package to a module
To convert a package to a module, follow these steps
- In the Project tool window, select the desired Python package (marked as ), or the nested file
__init__.py
. - On the menu, choose .
Example
Before | After |
---|---|
See Also
Reference:
Last modified: 23 December 2016