Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class MyClass:
  2.  
  3. def __init__(self,*args):
  4. self.Input = args
  5.  
  6. def __add__(self,Other):
  7. Output = MyClass()
  8. Output.Input = self.Input + Other.Input
  9. return Output
  10.  
  11. def __str__(self):
  12. Output = " "
  13. for Item in self.Input:
  14. Output += Item
  15. Output += " "
  16. return Output
  17.  
  18. Value1 = MyClass("Red", "Green", "Blue")
  19. Value2 = MyClass("Yellow", "Purple", "Cyan")
  20. Value3 = Values1 + Values2
  21.  
  22.  
  23. print("{0}+{1}={2}".format(Value1,Value2,Value3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement