DEV Community


Posted on • Updated on


Python Classes

Defining a Class in Python
A class is a blue print of an object. Where the class is the blue print of the house, the object is the actual house built.

Similar to how function definitions begin with a 'def' keyword in Python, class definitions begin with a 'class' keyword.

class MyNewClass:
  '''Docstring goes here. I have created a new class'''
Enter fullscreen mode Exit fullscreen mode
  1. Here we created a class named 'MyNewClass'. Notice we use the CapWords convention since PEP 8 Style Guide for Python Code recommends this for Class names.
  2. A docstring is not mandatory but highly recommended. It is written so programmers can understand what it does without having to read the details of the implementation.
  3. The 'pass' keyword is used in Python to indicate that the body of the class was intentionally left blank. This prevents an 'IndentationError' from occurring in the terminal.

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.