Gowtham SB
[Link]/in/sbgowtham/ Instagram - @dataengineeringtamil
🧠 Python OOP Guide: Instance Method
vs Class Method vs Static Method
🔧 What Are Utility / Helper Functions?
A utility/helper function is a reusable, small function that performs one specific
task and doesn't depend on any object (self) or class (cls) data.
✅ Example:
class StringTools:
@staticmethod
def to_upper(text):
return [Link]()
print(StringTools.to_upper("gowtham")) # 👉 GOWTHAM
📌 This is a pure utility — doesn't need class or object data.
🧱 3 Types of Methods in Python OOP
Method Decorator First Can Access Can Access Use Case
Type Parameter Object Class Data?
Data?
Instance None self ✅ Yes ✅ (indirectly Object-specific
via class) behavior
Class @classmeth cls ❌ No ✅ Yes Class-wide configs,
od alt constructor
Static @staticmet ❌ None ❌ No ❌ No Utility/helper
hod functions
Gowtham SB
[Link]/in/sbgowtham/ Instagram - @dataengineeringtamil
🔁 Example for Each Method Type
✅ Instance Method — works on object (self)
class Person:
def __init__(self, name):
[Link] = name
def greet(self): # Instance method
print(f"Hello, I'm {[Link]}")
p = Person("Gowtham")
[Link]() # 👉 Hello, I'm Gowtham
📌 Uses [Link] (object-level data)
✅ Class Method — works on class (cls)
class Company:
company_name = "OpenAI"
@classmethod
def set_company(cls, name):
cls.company_name = name
Company.set_company("Google")
print(Company.company_name) # 👉 Google
📌 Uses cls to modify class-level data
✅ Static Method — general utility (no self or cls)
class MathTools:
@staticmethod
def is_even(n):
return n % 2 == 0
print(MathTools.is_even(10)) # 👉 True
Gowtham SB
[Link]/in/sbgowtham/ Instagram - @dataengineeringtamil
📌 No access to object or class — pure utility
❓Why Not Use Instance or Class Method Always?
Because sometimes:
● You just need a tool function (like is_even(), to_upper())
● You don’t need to carry the weight of self or cls
● Static methods make your class cleaner
❌ Trying to access object data in classmethod or
staticmethod
class Test:
def __init__(self, name):
[Link] = name
@classmethod
def show_name_cls(cls):
try:
print([Link])
except Exception as e:
print("Class Method Error:", e)
@staticmethod
def show_name_static():
try:
print([Link])
except Exception as e:
print("Static Method Error:", e)
t = Test("Gowtham")
t.show_name_cls() # ❌ Class Method Error: name 'self' is not defined
t.show_name_static() # ❌ Static Method Error: name 'self' is not defined
Gowtham SB
[Link]/in/sbgowtham/ Instagram - @dataengineeringtamil
📌 self is not available in class/static methods!
🚀 Advantages of Inheritance
1. Code Reusability: Common logic from the parent can be reused in multiple child
classes.
2. Scalability: Easily extend or add new features by creating new subclasses.
3. Maintainability: Update code in one place (parent class) to reflect in all child classes.
4. Logical Grouping: Helps organize similar objects in a clear, hierarchical way.
5. DRY Principle: "Don’t Repeat Yourself" — reduces duplicate code.
6. Supports Polymorphism: Child classes can override methods for custom behavior.
🎯 Summary Table
Feature Instance Class Method Static Method
Method
Needs object ✅ Yes ❌ No ❌ No
Needs class ✅ Yes ✅ Yes ❌ No
Decorator ❌ No ✅ Yes ✅ Yes
required?
Common use Object behavior Alternate constructors / class Utilities (math,
config format)
About the Author
Gowtham SB is a Data Engineering expert, educator, and content creator with a
passion for big data technologies, as well as cloud and Gen AI . With years of
experience in the field, he has worked extensively with cloud platforms, distributed
systems, and data pipelines, helping professionals and aspiring engineers master the
art of data engineering.
Beyond his technical expertise, Gowtham is a renowned mentor and speaker, sharing
his insights through engaging content on YouTube and LinkedIn. He has built one of
Gowtham SB
[Link]/in/sbgowtham/ Instagram - @dataengineeringtamil
the largest Tamil Data Engineering communities, guiding thousands of learners to
excel in their careers.
Through his deep industry knowledge and hands-on approach, Gowtham continues to
bridge the gap between learning and real-world implementation, empowering
individuals to build scalable, high-performance data solutions.
𝐒𝐨𝐜𝐢𝐚𝐥𝐬
𝐘𝐨𝐮𝐓𝐮𝐛𝐞 - [Link]
𝐈𝐧𝐬𝐭𝐚𝐠𝐫𝐚𝐦 - [Link]
𝐈𝐧𝐬𝐭𝐚𝐠𝐫𝐚𝐦 - [Link]
𝐂𝐨𝐧𝐧𝐞𝐜𝐭 𝐟𝐨𝐫 𝟏:𝟏 - [Link]
𝐋𝐢𝐧𝐤𝐞𝐝𝐈𝐧 - [Link]
𝐖𝐞𝐛𝐬𝐢𝐭𝐞 - [Link]
𝐆𝐢𝐭𝐇𝐮𝐛 - [Link]
𝐖𝐡𝐚𝐭𝐬 𝐀𝐩𝐩 - [Link]
𝐄𝐦𝐚𝐢𝐥 - [Link]@[Link]
𝐀𝐥𝐥 𝐌𝐲 𝐒𝐨𝐜𝐢𝐚𝐥𝐬 - [Link]