fork download
  1. class Cars:
  2.  
  3. def maker(self, mkr):
  4. self.maker = mkr
  5. return self
  6.  
  7. def model(self, mdl):
  8. self.model = mdl
  9. return self
  10.  
  11. def year(self, yr):
  12. self.year = yr
  13. return self
  14.  
  15. def price(self, prc):
  16. self.price = prc
  17. return self
  18.  
  19. def miles(self, mile):
  20. self.miles = mile
  21. return self
  22.  
  23. def show_detail(self):
  24. print("Maker:", self.maker, "Model:", self.model, "Year:",
  25. self.year, "Price:", self.price, "Miles:", self.miles)
  26.  
  27. c = Cars()
  28.  
  29. c.maker("Aston Martin").model("DB9").year(
  30. 2004).price(149.000).miles(30).show_detail()
Success #stdin #stdout 0.02s 9936KB
stdin
Standard input is empty
stdout
Maker: Aston Martin Model: DB9 Year: 2004 Price: 149.0 Miles: 30