Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python class set dict method

class MyObject():
	
    def __init__(self):
      	self.a = 1
     	self.b = 2
      	self.c = 3
      
	def __iter__(self):
    	yield 'a', self.a
    	yield 'b', self.b
    	yield 'c', self.c

dict(MyObject())

>>>
{
  'a': 1,
  'b': 2,
  'c': 3
}
Comment

PREVIOUS NEXT
Code Example
Python :: get variable from function python 
Python :: geopandas replace column name 
Python :: how to save python-pptx 
Python :: how to open youtube from google chrome browser instead of internet explorerwhen coding in python 
Python :: change excel value in python 
Python :: arma-garch model python 
Python :: concatenate strings of numpy array python 
Python :: tkinter auto resize height 
Python :: python telegram bot async 
Python :: difference between 2 dataframes 
Python :: authentication serializer drf 
Python :: generative art python 
Python :: find a character in a string python last 
Python :: how can I convert dataframe to list with in python without changing its datatype? 
Python :: add text to axis 
Python :: Function in python with input method 
Python :: tensorflow create custom initializer 
Python :: series object has no attribute split 
Python :: python how to invert an array 
Python :: check dictionary values pandas dataframe colu 
Python :: Lucky four codechef solution 
Python :: python vector class 
Python :: how to sort a list 
Python :: apply 2d mask to 3d array python 
Python :: get fields in object python 
Python :: apps to help in coding python exmas 
Python :: explicitly free memory in Python code 
Python :: django swagger 
Python :: python comments 
Python :: Generate bar plot python 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =