Delete attributes from an instance in Python
`del`, a Python built-in function, deletes the instance's property. python class Account: def __init__(self, name): self.na...
Python class
What is Python class or what is class in programming language? When questioned "What is class?" or "Why do most programmers use class?", I alway...
Python hasattr() - How to check if the object or instance has an attribute or property
The `hasattr()` checks if the object or instance has an attribute. It is a [built-in function](/python-built-in) in Python. python class Us...
Python class @property
The @property method in Python class can be accessed as a property or attribute. python class Triangle: def __init__(self, width, he...
Python nested function and decorator - How to use a function that returns another function object
A Python function can return the function. python def f(): def g(): print('g() is called.') return g() f() # g()...
The difference of isinstance and type in Python
The `type()` and `isinstance()` are Python built-in functions that checks the type of an object. python class Food: pass i = isin...
Python staticmethod - The method called by the class and instance
The Python static method is declared by @staticmethod decorator. python class Account: def __init__(self, name): self.name ...
Python classmethod - Get the class name from the class or instance
The Python class method is declared by @classmethod decorator. python class Account: def __init__(self, name): self.name = ...
Python __str__ : How or when to use __str__ method
Python object (class instance) has `__str__` method that returns the information of a object as string, which is almost meaningless by defualt. ...
Private variables in Python Class: Difference of public and private attributes
Python class has public and private attributes like other languages. The name of private attribute starts with double underscores. python c...
Python __subclasses__ and how to get child class name from parent class
When a class has a parent class in Python, we can get the child class name from the parent class. python class Product: def __init__...
Get a class name in Python - How to use __class__ and __name__
Python instance (object) has the `__class__` attribute and it has the `__name__` attribute, which is the class name of an instance. python ...
Python overloading operator - Add, subtract, multiply objects using arithmetic operators
Python string can be added using plus symbol as if strings were numbers. You can define addition to class object using `__add__` function. p...
Python Class - Get dictionary of class instance (__dict__ and vars)
Python class instance has `__dict__` method. We can get the dictionary of class instance attributes as follow. python class Employee: ...
Python String
Python List
Python Tuple
Python Set
Python Dictionary
Python Float
Python Decimal
Python Fraction
Python Date & Time
Python Function
Python Class
Python File
Python Built in
Python Math
Python Counter
Python Functools
Python Itertools
Python Deque
Python Tips
© Rollpie