I'm having trouble understanding what a class instance is. I read up on the syntax page for classes in python. However, i'm still having difficulty fully grasping the meaning of an instance. For example, lets say I create a class that has two slots containing an "item" and a "key". In my case, I know how to initialize the objects using def __init__(self): with self.key = key and self.name = name. However, my problem deals with creating an instance that takes in two parameters. Similarly, how would I make an instance a stack? I don't really want any code, however can someone describe the solution in simple terms? Thanks guys!
@drewk -
class morning(object):
__slots__ = ('key', 'name')
def __init__(self, name, key):
self.name = name
self.key = key
return self
make an instance a stack?classmorning is just the code. When you call the class first time to create an object that belongs to thisclasscategory, you get an instance of that class. Hope that clears things up.return selfin__init__, the instance is returned by default.