Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

can we put the object as value in a dictionary in python*

class MyObject():
    def getName(self):
       return self.name

    def getValue(self):
       return self.value

    def __init__(self,name, value):
       self.name = name
       self.value = value


dict = {}
object = MyObject('foo', 2) //foo is the name, 2 is the value
dict[object.getName()] = object
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #put #object #dictionary
ADD COMMENT
Topic
Name
6+8 =