Skip to content

Instantly share code, notes, and snippets.

Created Jul 14, 2020
What would you like to do?
class Student:
def __init__(self,name,rollno):
def __repr__(self):
return "{},{}".format(,self.rollno)
print (
#Unable to access attributes having leading double underscore.
print (s.__rollno)#Output:AttributeError: 'Student' object has no attribute '__rollno'
#Name Mangling - have to use class extension with variable name
print (s._Student__rollno)#Output: 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment