Open sammysignal opened 3 years ago
Thank you for this finding! Your idea to return self
sounds interesting; I'm not used to overriding __getitem__
so I'd say go for it if you think that's the better way.
I'm just concerned about one thing: if there are people who already use this module, would they need to change their code after the update?
Honestly it's very exciting to have other people use this module so thank you for looking into this!
Cool I just made a PR for it, yes I do think its better to return self but its not a big deal either way. PR also includes making the deck iterable and indexable.
And I don't think clients would have to change their code - you could make a new release and they would only have to change their code after upgrading the module using pip3 install --upgrade
or something like that.
I noticed that the documentation indicates that methods
add_deck
,order_deck
,shuffle_deck
,reset_deck
are returning deck objects, but that's not actually the case - they are instead returning a list of cards which is a bit confusing. It may be fine to return a list of cards, as long as the docs are updated, however, you could also instead simply returnself
. If we returnself
we could also write a__getitem__
function so that you can index directly into the cards object (e.g.,card_obj[0]
) - that way it would feel more like a list.happy to make a pr for either option, curious which way you prefer.