Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created February 12, 2022 11:39
Show Gist options
  • Save StephenFordham/a36157ab4ef8150482d43661bbc47195 to your computer and use it in GitHub Desktop.
Save StephenFordham/a36157ab4ef8150482d43661bbc47195 to your computer and use it in GitHub Desktop.
Unusual ways to control attrbute access in Python, Example 1
emp = Employees('stephen', 'bournemouth', 30)
for key, value in emp.__dict__.items():
print('{} = {}'.format(key, value))
emp('Simon')
print('#####################################')
for key, value in emp.__dict__.items():
print('{} = {}'.format(key, value))
# Terminal Output
_name = stephen
_age = 30
_location = bournemouth
#####################################
_name = Simon
_age = 30
_location = bournemouth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment