Reputation:
Here's my code:
class Pop(object):
def holder(self):
self.boobs = 16
self.sent = "pop"
def together(self):
print "%s : %i" % (self.sent, self.boobs)
pop = Pop()
pop.together()
Shouldn't this print "pop : 16"? Sorry for the odd variable names :P
Also, I'm new to self. Thanks.
Upvotes: 1
Views: 295
Reputation: 17590
In your example, you should first call holder
, because that sets the variable to 16.
I think you meant to do this:
class Pop(object):
def __init__(self):
self.boobs = 16
self.sent = "pop"
def together(self):
print "%s : %i" % (self.sent, self.boobs)
pop = Pop()
pop.together()
Upvotes: 10