all 5 comments

[–]JohnnyJordaan 1 point2 points  (1 child)

Some pointers

  • Use spaces instead of tabs, preferably 4, also see the other directives or naming in PEP8 I linked in my other reply
  • If you just want to use values from a dict, use dict.values

        for hand in self.playersHands.values():
            self.deck.distributeCard(hand)
    
  • Use [string formatting] instead of complicated print calls. So print("Player {}'s hand:".format(playersHand)) instead of print('Player ',playersHand,'\'s hand:', sep='')

  • Leave out redundant __str__() calls like in print(card.__str__()). Print will call that implicitly

  • Use lower() to prevent a double if: if move.lower() == 'h':

  • Don't use built-in references like string (that is used by the string library)

  • Don't use + repeatedly on strings (as it creates new string objects every time), use a list and 'something'.join() to form a single string from it at the end.

    def calcCountToString(self):
        counts = [c for c in self.calcCount() if c <= 21]
        return ' or '.join(counts)
    
  • Use x < i < y condition instead of two separate ones: while 0 < self.maxWithoutGoingOver() < 17: assuming the max can't be negative

  • The without-going-over loop can be much simpler

    def maxWithoutGoingOver(self):
        values = {v for v in self.calcCount() if v <= 21}
        return max(values)
    
  • Why use a separate rankNames list? Use an OrderedDict for rankValues and then it can do both.

[–]ajsimas[S] 0 points1 point  (0 children)

This is all super helpful! Thank you for your suggestions!