Created
February 12, 2022 11:16
-
-
Save StephenFordham/bccd384de6d8e71b1b3cce71a0d8c55f to your computer and use it in GitHub Desktop.
Unusual ways to control attrbute access in Python, Example 1
This file contains hidden or 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
class Employees(object): | |
def __init__(self, name, location, age): | |
self._name = name | |
self._age = age | |
self._location = location | |
emp = Employees('stephen', 'bournemouth', 30) | |
for key, value in emp.__dict__.items(): | |
print('{} = {}'.format(key, value)) | |
# Terminal output | |
_name = stephen | |
_age = 30 | |
_location = bournemouth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment