Search
 
SCRIPT & CODE EXAMPLE
 

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 :: Python how to use __le__ 
Python :: python interpreter after running a python file 
Python :: modles en django 
Python :: NumPy trim_zeros Syntax 
Python :: Program to get number of consecutive repeated substring 
Python :: calculate mse loss python 
Python :: godot knockback 
Python :: saving specific column with pd 
Python :: NumPy unpackbits Syntax 
Python :: django view - Generic class based view (listc, create, retrieve, update or delete - GET, POST, GET, PUT, DELETE) 
Python :: pandas aggregate rename column 
Python :: enumerate and looping backward 
Python :: python decouple default value 
Python :: Remove Brackets from List Using for loop 
Python :: list python !g 
Python :: How to set a tkinter window to a constant size 
Python :: Compress multiple directories but exclude directory - Python zipfile(or anything native to Windows 2012+ 
Python :: pixel accuracy image segmentation python 
Python :: pyxl activate sheet 
Python :: django assign authenticated user to foreign user 
Python :: Flask/Werkzeug, how to return previous page after login 
Python :: tdlib python 
Python :: postgres fecth python 
Python :: ring write the same example using normal for loop the Encrypt() and Decrypt() functions. 
Python :: ring Trace library usage to pass an error 
Python :: view scrapy response in chrome from inside the spider 
Python :: How to make exit button? 
Python :: poset save @reciever created 
Python :: how to read then overwrite a file with python with truncate 
Python :: 2checkout ipn validation response python 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =