Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #class #set #dict #method
ADD COMMENT
Topic
Name
4+1 =