Skip to content

Commit

Permalink
Update chapter28.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
nickcafferry committed Jan 16, 2022
1 parent f065154 commit 932c235
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions source/chapter28.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,27 @@ The main distinction for classes is that :strong:`their namespaces are also the
def method(self,...):
self.member = value
.. code:: python
>>> class SharedData:
global spam
spam = 42
def __init__(self):
self.spam = spam
class subclass():
def __init__(self,spam):
super().__init__()
self.spam = spam
def __str__(self):
return str(self.spam)
>>> example1 = SharedData()
example1.spam
... 42
>>> example2 = example1.subclass(32)
>>> print(example2)
... 32
.. raw:: html
:file: Chapter28.html

0 comments on commit 932c235

Please sign in to comment.