Skip to content

Commit 9e0ce01

Browse files
committed
Chapter 4
1 parent 5a653e4 commit 9e0ce01

13 files changed

Lines changed: 53 additions & 0 deletions

File tree

Ch4/example.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from testpkg import awesome
2+
3+
print(__name__) # print "__main__"
4+
print(awesome.__name__) # prints "testpkg.awesome"

Ch4/rocket_usage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from rockets import SmallRocket, Launchpad
2+
3+
pad = Launchpad(SmallRocket())
4+
pad.launch()

Ch4/rockets/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .smallrocket.rocket import SmallRocket
2+
from .largerocket.rocket import LargeRocket
3+
from .launchpad.pad import Launchpad
4+
5+
__all__ = ["SmallRocket", "LargeRocket", "Launchpad"]

Ch4/rockets/largerocket/__init__.py

Whitespace-only changes.

Ch4/rockets/largerocket/rocket.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class LargeRocket:
2+
def launch():
3+
print("WHOOOOOOSSSHHHH!")

Ch4/rockets/launchpad/__init__.py

Whitespace-only changes.

Ch4/rockets/launchpad/pad.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Launchpad:
2+
def __init__(self, rocket):
3+
self.rocket = rocket
4+
5+
def launch(self):
6+
self.rocket.launch()

Ch4/rockets/smallrocket/__init__.py

Whitespace-only changes.

Ch4/rockets/smallrocket/rocket.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class SmallRocket:
2+
def launch(self):
3+
print("whoosh")

Ch4/smart_door.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python3
2+
3+
4+
def open():
5+
print("Ahhhhhhhhhhhhhh.")
6+
7+
8+
def close():
9+
print("Thank you for making a simple door very happy.")

0 commit comments

Comments
 (0)