Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python __ge__

"""
Magic method __ge__ stands for greater than or equal. So this magic method defines or 
overwrites what should ">=" sign do with objects.
"""

class Test:
    def __init__(self, x):
        self.x = x
    
    def __ge__(self, other):
        """
		Compares attribute "x" of objects, self stands for 1st object
		and other stands for object after ">=" sign. (so t is self and t2 other)
		"""
        return self.x >= other.x	# Should be used on objects of the same type

t = Test(2)
t2 = Test(2)
print(t >= t2)	# Now I call the __ge__ method by using ">=" sign.
Comment

PREVIOUS NEXT
Code Example
Python :: __sub__ 
Python :: Python how to use __div__ 
Python :: __le__ 
Python :: Exception has occurred: FileNotFoundError 
Python :: how to get defintiion of pysspark teable 
Python :: Program to get number of consecutive repeated substring 
Python :: use every character with python to get probabilities 
Python :: ignopre rankwarning pyton 
Python :: NumPy bitwise_xor Code When inputs are arrays 
Python :: URL to origin python 
Python :: ax bar different colors 
Python :: python override inherited method class model constructor 
Python :: python restrict function parameter type 
Python :: how to use python telegram filters 
Python :: python replace date time column 
Python :: add ing to the end of a string or add ly if the string ends with ing python 
Python :: combination in python without itertools 
Python :: preallocate numpy array 
Python :: How to allow discord bot to respond to webhook. Python. Discord.py 
Python :: tkinter screen clicked 
Python :: SQLAlchemy ordering by count on a many to many relationship 
Python :: how to make a typing effect in python 
Python :: flask login attemted_user cant see check_password_correction method 
Python :: ring Creating a Multi-Dimensional Array using List 
Python :: word cloud mape python 
Python :: remove kernel 
Python :: Proper Case django template 
Python :: how to use random ranint 
Python :: screen.blit() arguments 
Python :: pls help i need tkintwr help plspslspslspsl help tkinter 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =