Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created February 12, 2022 11:16
Show Gist options
  • Save StephenFordham/bccd384de6d8e71b1b3cce71a0d8c55f to your computer and use it in GitHub Desktop.
Save StephenFordham/bccd384de6d8e71b1b3cce71a0d8c55f to your computer and use it in GitHub Desktop.
Unusual ways to control attrbute access in Python, Example 1
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