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
- 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
- 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 |
|---|---|
![]() | ![]() |



