Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created February 12, 2022 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephenFordham/4842d29a9ccf8da633f31790e4235562 to your computer and use it in GitHub Desktop.
Save StephenFordham/4842d29a9ccf8da633f31790e4235562 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))
print('###################################')
emp(location='newloc')
for key, value in emp.__dict__.items():
print('{} = {}'.format(key, value))
# Terminal Output
_name = stephen
_age = 30
_location = bournemouth
###################################
_name = stephen
_age = 30
_location = newloc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment