Advertisement
simeonshopov

Article

Jan 21st, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. class Article:
  2.     def __init__(self, title, content, author):
  3.         self.title = title
  4.         self.content = content
  5.         self.author = author
  6.  
  7.     def edit(self, new_content):
  8.         self.content = new_content
  9.  
  10.     def change_author(self, new_author):
  11.         self.author = new_author
  12.  
  13.     def rename(self, new_title):
  14.         self.title = new_title
  15.  
  16.     def __repr__(self):
  17.         return f"{self.title} - {self.content}: {self.author}"
  18.  
  19.  
  20. article = Article("some title", "some content", "some author")
  21. article.edit("new content")
  22. article.rename("new title")
  23. article.change_author("new author")
  24. print(article)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement