1

I'm trying to get into Object-Oriented Programming for Python, but I definitely don't have the Programming literacy to understand any guides out there. I would be grateful if anyone could help me understand how to use and clarify the differences between "normal functions", "@class method", and "@static method" in a way that a beginner like me could understand.

A guide that I had no clue how to use, https://www.geeksforgeeks.org/class-method-vs-static-method-python/.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

1

Object State

Object state is the state of your variables inside the scope of an object.

Class State

Class state is the state of your variables which are defined class-wide. Class variables are available to all instances of that class, not instance specific that is.

Instance Methods

You call these normal functions, these are used to interact with object state. They get/set or do stuff with your variables inside the object.

Class Methods

These have access to the class-wide variables and may perform operations on them, but they cannot modify object state, obviously.

Static Methods

These are not related to the class or the objects derived from that class in anyway. It is a normal function that can be very well defined outside of the scope of your class. You define methods as static just to apply namespacing on them.

Sıddık Açıl
  • 957
  • 8
  • 18