On Friday, November 28, 2014 7:51:40 PM UTC+5:30, Rustom Mody wrote: > On Friday, November 28, 2014 6:57:23 AM UTC+5:30, Seymore4Head wrote: > > def __str__(self): > > s = "Hand contains " > > for x in self.hand: > > s = s + str(x) + " " > > return s > > > > This is part of a Hand class. I need a hand for the dealer and a hand > > for the player. > > dealer=Hand() > > player=Hand() > > This prints out 'Hand contains " foo bar > > for both the dealer's hand and the player's hand. > > > > Is there a way to include "self" in the __string__ so it reads > > Dealer hand contains foo bar > > Player hand contains foo bar > > And what do you think should be printed if instead of your code > > dealer = Hand() > player = Hand() > > we have the following > > dealer = Hand() > player = dealer > > ??
Sorry for repeating -- I see Steven said the same -- https://mail.python.org/mailman/listinfo/python-list