Python: Learning Classes and Objects in a practical way

Last Updated on August 7, 2022 by shibatau

I. How to learn Classes and Objects

Classes and objects seem complicated and difficult to understand when you are just beginning to learn Python and if you don’t have any previous experience with Object-Oriented Programming. In my experience, it is the best way to create the codes for your everyday use when they look difficult.

Now I have created classes and objects for my booklist. Of course, you can create your booklist using a data frame or a dictionary but you can learn Classes and Objects by using these codes. Actually, I often use classes and objects in Python for my daily use and I feel they are they are elegant and cool.

You can learn the basics of Object Oriented Programming and the codes here:

Python – Object Oriented

II. Creating a booklist using Classes and Objects

# create a class for my booklist
class BookList:
   'My booklist that Im reading now'
   reading = 0

   def __init__(self, title, author, published):
      self.title = title = author
      self.published = published
      BookList.reading += 1
   def countnumber(self):
      print(f"Total book is {BookList.reading}")

   def all(self):
      nl = '\n'
      print(f"Title: {self.title},\
      Author: {},\
      Published: {self.published}\
      {nl}This is one of the {BookList.reading} books that you are reding.")

Now you can show the information of the book:

III. The scripts

You can see the scripts here:

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.