Skip to content

Commit

Permalink
Merge pull request #2994 from enkidevs/classes-iii
Browse files Browse the repository at this point in the history
Classes iii
  • Loading branch information
Stefan-Stojanovic authored Mar 15, 2023
2 parents 1686075 + 31ae7ee commit 380375e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ Types of change:
### Changed
- [Html - Link Relative Paths - Change part of PQ as it wasn't worder properly](https://github.com/enkidevs/curriculum/pull/2985)
- [Python - Format Text Paragraphs With Textwrap - Make the fill method more clear](https://github.com/enkidevs/curriculum/pull/2981)
- [Python - Classes III - Move single-line commands to a single line, update indentation in codeblocks from 4 to 2 spaces](https://github.com/enkidevs/curriculum/pull/2994)
- [Python - Advanced Referencing - Move single-line commands to a single line, update indentation in codeblocks from 4 to 2 spaces](https://github.com/enkidevs/curriculum/pull/2989)
- [Python - Python Recipes - Move single-line commands to a single line, update indentation in codeblocks from 4 to 2 spaces](https://github.com/enkidevs/curriculum/pull/3009)
- [Python - Is Your Python Healthy - Move single-line commands to a single line, update indentation in codeblocks from 4 to 2 spaces](https://github.com/enkidevs/curriculum/pull/2999)
Expand Down
11 changes: 4 additions & 7 deletions python/python-core/classes-iii/dynamically-create-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This `type` function takes three arguments:
- `bases` - list of superclasses
- `dict` - dictionary of attributes

These two classes implement the same functionality although syntacticly different
These two classes implement the same functionality although syntactically different:

```python
# The name is set to "BigCar"
Expand All @@ -55,12 +55,9 @@ def Car_init(self, name):
self.name = name

# We can choose the name of a class
SmallCar = type("BigCar",
(),
{"counter": 0,
"__init__": Car_init,
"beep": lambda self: "Beep " +
self.name})
SmallCar = type("BigCar", (), \
{"counter": 0, "__init__": Car_init, \
"beep": lambda self: "Beep " + self.name})
```

So now these two classes are practically identical (`__name__` property is also equal), the only difference can be seen in types, which does not affect the functionality:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Suppose we have the class:

```python
class Enki:
pi = 3.14
pi = 3.14
```

Get all **writable** attributes of your `class object`:
Expand Down

0 comments on commit 380375e

Please sign in to comment.