Skip to content

Instantly share code, notes, and snippets.

@evandixon
evandixon / gist:9465da1fa681b3830bafd5df31af7500
Created December 15, 2020 21:22
Private variables in Python are a mere suggestion
class privateData:
def __init__(self):
self.__whatever__ = "The Good Value"
def doTheThing(self):
print(self.__whatever)
private = privateData()
privateData._privateData__whatever = "The bad value"
privateData.doTheThing(private)
@evandixon
evandixon / gist:8f1d2e1f8f93598debe20ad2d385a971
Created December 15, 2020 21:10
Python's "There we did it" syntax - Things I shouldn't be able to do
#Class creation is a hack
class iShouldntBeAbleToDoAnyOfThis:
def __new__(self):
#Think long and hard before doing this in reality
return theRealClass()
def doTheThing(self):
print("Do the thing")
class theRealClass():