Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

objects list

# Python3 code here for creating class
class geeks:
	def __init__(self, x, y):
		self.x = x
		self.y = y
		
	def Sum(self):
		print( self.x + self.y )

# creating list	
list = []

# appending instances to list
list.append( geeks(2, 3) )
list.append( geeks(12, 13) )
list.append( geeks(22, 33) )

for obj in list:
	# calling method
	obj.Sum()

# We can also access instances method
# as list[0].Sum() , list[1].Sum() and so on.
Comment

PREVIOUS NEXT
Code Example
Python :: vocal remover source code python 
Python :: verbose field names 
Python :: Python NumPy insert Function Example Working with Scalars 
Python :: Python NumPy hsplit Function Syntax 
Python :: get method from plot 
Python :: (ax=self.canv.axes ,style="ro--") 
Python :: pandas dt.weekday to string 
Python :: Python __truediv__ magic method 
Python :: how to fetch limited rows in pandas dataframe using sqlalchemy 
Python :: what are while loops in python 
Python :: get forex exchange rates in python 
Python :: NumPy bitwise_xor Code When inputs are numbers 
Python :: lambda function in python to shut ec2 at the time zone 
Python :: Termfastapi get ip 
Python :: cast set 
Python :: first index of an integer less than a value 
Python :: celery 5.2.3 decorators 
Python :: ccacxc 
Python :: pandas dataframe select columns multiple cell value 
Python :: get distance between points in 1 array pythoin 
Python :: pyqt serial plotter 
Python :: how to show type of a variable 
Python :: python pandas to visualise the tangent of a curve 
Python :: EDA describe missing and zero values 
Python :: sns.kdeplot make line more detailed 
Python :: negative max in python 
Python :: ring Creating Reports using the WebLib and the GUILib 
Python :: Problems with flask bootstrap 
Python :: how to know google index of a page using python 
Python :: attribute error rest framework 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =