...
 
Commits (6)
__pycache__ __pycache__
.cache .cache
.*.sw* .*.sw*
*.pyc
...@@ -28,3 +28,19 @@ Features ...@@ -28,3 +28,19 @@ Features
* Encapsulation * Encapsulation
Running The Tests
====
First you do:
```
export PYTHONPATH=.
```
Then you can do:
```
python3 test_oop.py
```
The test passes if you get NO output.
...@@ -28,3 +28,20 @@ Features ...@@ -28,3 +28,20 @@ Features
* Encapsulation * Encapsulation
Running The Tests
====
First you do:
```
export PYTHONPATH=.
```
Then you can do:
```
python3 test_oop.py
```
The test passes if you get NO output.
...@@ -22,4 +22,6 @@ def test_new_class_no_getset(): ...@@ -22,4 +22,6 @@ def test_new_class_no_getset():
set(b, 'color', 'red') set(b, 'color', 'red')
assert get(b, 'color') == 'red' assert get(b, 'color') == 'red'
call(b, 'drive', 'Texas')
test_new()
test_new_class_no_getset()
...@@ -28,3 +28,19 @@ Features ...@@ -28,3 +28,19 @@ Features
* Encapsulation * Encapsulation
Running The Tests
====
First you do:
```
export PYTHONPATH=.
```
Then you can do:
```
python3 test_oop.py
```
The test passes if you get NO output.
...@@ -42,16 +42,6 @@ def test_obj_methods(): ...@@ -42,16 +42,6 @@ def test_obj_methods():
c.drive("Zed", "Texas") c.drive("Zed", "Texas")
test_new()
test_new_class_no_getset()
test_obj_methods()
...@@ -28,3 +28,19 @@ Features ...@@ -28,3 +28,19 @@ Features
* Encapsulation * Encapsulation
Running The Tests
====
First you do:
```
export PYTHONPATH=.
```
Then you can do:
```
python3 test_oop.py
```
The test passes if you get NO output.
...@@ -56,4 +56,10 @@ def test_inheritance(): ...@@ -56,4 +56,10 @@ def test_inheritance():
assert get(a, 'fresh') == False assert get(a, 'fresh') == False
Apple.throw(a, 'Zed') Apple.throw(a, 'Zed')
test_new()
test_new_class_no_getset()
test_obj_methods()
test_inheritance()
...@@ -28,3 +28,19 @@ Features ...@@ -28,3 +28,19 @@ Features
* Encapsulation * Encapsulation
Running The Tests
====
First you do:
```
export PYTHONPATH=.
```
Then you can do:
```
python3 test_oop.py
```
The test passes if you get NO output.
...@@ -65,3 +65,9 @@ def test_inheritance(): ...@@ -65,3 +65,9 @@ def test_inheritance():
mycar = new(Buick, 'green') mycar = new(Buick, 'green')
Buick.drive(mycar) Buick.drive(mycar)
test_new()
test_new_class_no_getset()
test_obj_methods()
test_inheritance()
This is the start of a hand-crafted Object Oriented System using just basic Python capabilities such as modules, function calls, and dicts. It's intended to be an educational look at how an OOP system works so that you can understand it in depth. I (Zed Shaw) will slowly build the system up from basics until it's functional enough, and then potentially implement a different kind of OOP that is foreign to Python.
This repository is the one I use in the videos for the Learn Code Live OOP School series of videos.
Design Questions
=========
* All the features of OOP, OR all the features people use?
* Do we do a python style OOP, or do we do a message passing system.
* Do we need efficiency?
Answers for First Attempt
====
* Mostly the features people use.
- No MRO
* Python style OOP.
- No message passing.
* Not worry about efficiency.
Features
====
* Functions on data.
* Subclass so a missing function will look at a parent class.
* Type information.
* Define a class, and then make objects from it.
* Encapsulation
Running The Tests
====
First you do:
```
export PYTHONPATH=.
```
Then you can do:
```
python3 test_oop.py
```
The test passes if you get NO output.
...@@ -65,3 +65,9 @@ def test_inheritance(): ...@@ -65,3 +65,9 @@ def test_inheritance():
mycar = new(Buick, 'green') mycar = new(Buick, 'green')
Buick.drive(mycar) Buick.drive(mycar)
test_new()
test_new_class_no_getset()
test_obj_methods()
test_inheritance()