Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Toggleable(object):
- def __init__(self, boolean):
- self.boolean = boolean
- def __repr__(self):
- return str(self.boolean)
- def toggle(self):
- if self.boolean == True:
- self.boolean = False
- elif self.boolean == False:
- self.boolean = True
- def main():
- a = Toggleable(True)
- print a #true
- a.toggle()
- print a #false
- a.toggle()
- print a #true
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement