Skip to content

Commit 30afa09

Browse files
authored
Merge pull request #680 from realpython/python-init-py
Add Python __init__.py tutorial materials
2 parents fbafeff + d50edf7 commit 30afa09

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

python-init-py/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# What Is Python's `__init__.py` For?
2+
3+
This folder contains the code discussed in the Real Python tutorial on [Python's `__init__.py` file](https://realpython.com/python-init-py/).
4+
5+
You can start a Python interpreter inside this folder, then interact with the modules like shown in the tutorial. Some of the code is currently commented-out. Follow the tutorial instructions for when to uncomment.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# print(f"Importing {__name__}")
2+
3+
__version__ = "0.1.0"
4+
5+
# from .audio.utils import enhance as audio_enhance
6+
# from .audio.utils import wobbulate
7+
# from .graphics.utils import enhance as graphics_enhance
8+
# from .graphics.utils import solarize
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# print(f"Importing {__name__}")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# print(f"Importing {__name__}")
2+
3+
4+
def wobbulate():
5+
print("Wibble wobble")
6+
7+
8+
def enhance():
9+
print("Enhancing audio")
10+
11+
12+
_secret_password = "Alakazam!"
13+
__top_secret_password = "!mazakalA"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# print(f"Importing {__name__}")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# print(f"Importing {__name__}")
2+
3+
__all__ = ["solarize", "enhance"]
4+
5+
6+
def solarize():
7+
print("Solarizing")
8+
9+
10+
def enhance():
11+
print("Enhancing graphics")
12+
13+
14+
indiana_pi = 3.2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__version__ = "1.0.0"
2+
magic_number = 42

0 commit comments

Comments
 (0)