Skip to content

Commit

Permalink
Merge pull request #2989 from enkidevs/advanced-referencing
Browse files Browse the repository at this point in the history
Advanced referencing
  • Loading branch information
Stefan-Stojanovic authored Mar 15, 2023
2 parents d59ba10 + eea7652 commit 1686075
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 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 - 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)
- [Python - Memory Allocation - Move single-line commands to a single line, update indentation in codeblocks from 4 to 2 spaces, grammar improvements](https://github.com/enkidevs/curriculum/pull/3002)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ To implement a custom **context manager**, two methods must be implemented:
```python
class my_context_manager:
def __enter__(self):
# set up things
return thing
# set up things
return thing
def __exit__(self,type,value,traceback):
# deal with unmanaged resources
# deal with unmanaged resources
#....
with my_context_manager as custom_name
# work with resources
# work with resources

```

Expand All @@ -80,14 +80,13 @@ Complete the code snippet to implement a context manager:
```python
class new_context_manager:
def ???(self):
# set up things
return thing
def ???(self, type,
value, traceback):
# deal with unmanaged resources
# set up things
return thing
def ???(self, type, value, traceback):
# deal with unmanaged resources

with new_context_manager as custom_name
# work with resources
# work with resources
```

- `__enter__`
Expand Down
4 changes: 2 additions & 2 deletions python/python-core/advanced-referencing/weakref-proxies.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ The difference is that proxies can be used without calling the `ref` first to ac
import weakref

class Enki(object):
def __init__(self, arg):
self.arg = arg
def __init__(self, arg):
self.arg = arg

enki = Enki('arg')
r = weakref.ref(enki)
Expand Down

0 comments on commit 1686075

Please sign in to comment.