Skip to content

Commit c1b8f49

Browse files
Merge pull request #11 from leapfrogtechnology/python
Python Changes
2 parents 44c8812 + 59ebec2 commit c1b8f49

File tree

14 files changed

+906
-87
lines changed

14 files changed

+906
-87
lines changed

docs/python/classes.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ sidebar_label: Classes
88

99
* Avoid inbuilt names.
1010
* Classes names should always be `PascalCase`. i.e. `MyClass`
11-
* Even if you are building datatypes based on inbuilt class use PascalCase. i.e. `MyDict(dict):`
12-
* Describe the class resposibility in name.
11+
* **Abstract Classes and Mixins**
12+
+ Use [abstract containers](https://docs.python.org/3/library/collections.abc.html#module-collections.abc) if need to override datatypes.
13+
- If you must build datatypes based on inbuilt class use PascalCase. i.e. `MyDict(dict):`.
14+
+ Use [`abc`](https://docs.python.org/3/library/abc.html) if you need pure OOP style abstract classes. Use `NotImplementedError` exceptions with overrides.
15+
+ mixin should be named with `Mixin` suffix such as `class LoginRequiredMixin` which can be used in multiple inheritance.
16+
* Describe the class responsibility in name.
1317
* Custom Exceptions should always be named ending with `Error` i.e. `MyCustomError`
18+
19+
##### Example
20+
21+
```python
22+
class HelloWorld:
23+
pass
24+
25+
class HelloWorldError(Exception):
26+
pass
27+
```

0 commit comments

Comments
 (0)