Created
February 12, 2022 11:50
-
-
Save StephenFordham/4842d29a9ccf8da633f31790e4235562 to your computer and use it in GitHub Desktop.
Unusual ways to control attrbute access in Python, Example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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