life is too short for a diary




Dear Vishi, daily log on July 11, 2022

Tags: diary letters

Author
Written by: Tushar Sharma
Featured image for Dear Vishi, daily log on July 11, 2022

Dear Vishi, this is my daily log for July 11, 2022.

Why sleep is like food

Since we live in a fast-paced world, we sometimes underestimate the importance of sleep. Often we sleep less on weekdays thinking we might compensate it by sleeping more on weekends. This is a common misconception. Adults need 7 or more hours of sleep per night for the best health and well-being.

According to a report by the CDC, people who get less than 7 hours of sleep per night have an increased risk of the following conditions:

I know life has its complexities. Sometimes we might have to delay sleeping due to work, unwarranted chores, or might need to watch a newly released sitcom on Netflix. But remember sleep is like food, the body needs it for nourishment. Don't sleep or eat like a hog on weekends too. The beauty lies in moderation for both food and sleep.

Magic methods in Python

Magic methods are methods that start with double underscores (eg init, lt). Today we are going to talk about __eq__ method. Lets say we have the following code

class Person:
    def __init__(self, name):
        self.name = name
        
person1 = Person("Tushar")
person2 = Person("Tushar")

print(person1 == person2)
# prints False

Both objects have same the name but different memory address. However if we want to override this behavior we can do

class Person:
  def __init__(self, name):
    self.name = name

  def __eq__(self, other):

    if isinstance(other, Person):
      return self.name == other.name
    else:
      return False

person1 = Person("Tushar")
person2 = Person("Tushar")

print(person1 == person2)
# prints True

Top five songs I liked today

Here's the list of top five songs that I listened to today incessantly.







comments powered by Disqus