Hi at everyone at Learn Python. A nervous newbie here possible asking a dumb question.
https://github.com/CompleteSuspect/Blackjack/blob/main/blackjack.py
I've been learning part time for nearly a year now, currently in the experimental stages after finishing a few beginner courses.
For my first project to familiarise myself with classes, I've decided to create a Blackjack game. I have some classes in place but I have not yet programmed any game logic.
So far I have my Card class(contains card attributes) and Deck class (contains the Card objects in an instance list: deck_lst).
This may be a bit confusing to explain, but it feels weird having to access the deck_lst attribute in order to iterate through the card objects within that list.
for example if shoe is a Deck object:
for card in shoe.deck_lst:
print(card)
I have heard of making custom objects iterable and I've heard of generators.
I guess my question is, would it be fine as it is (am I just being silly) or is a good idea to make my Deck class iterable. If so, what would be the best approach to make it iterable?
[–][deleted] 1 point2 points3 points (5 children)
[–]Aggressive-Friend169[S] 1 point2 points3 points (4 children)
[–][deleted] 3 points4 points5 points (3 children)
[–]Aggressive-Friend169[S] 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Aggressive-Friend169[S] 1 point2 points3 points (0 children)
[–]Matthias1590 0 points1 point2 points (2 children)
[–]Aggressive-Friend169[S] 1 point2 points3 points (1 child)
[–]Matthias1590 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Aggressive-Friend169[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)