You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The list_cards_iter doesn't work on second/multiple iterations because by default the query parameter is using the previous query value. The workaround is to just initialize the query parameter on each call. I'm just wondering if there's a reason for this or if it's a bug.
Here is some sample code where the list should be iterated twice:
for card in card_list.list_cards_iter(card_filter='all'):
print(card.name)
for card in card_list.list_cards_iter(card_filter='all'):
print(card.name)
Here is the workaround for actually iterating twice:
for card in card_list.list_cards_iter(card_filter='all', query={}):
print(card.name)
for card in card_list.list_cards_iter(card_filter='all', query={}):
print(card.name)
On Thu, Mar 12, 2020 at 6:33 PM Matthew Silverstein < ***@***.***> wrote:
Hey,
The list_cards_iter doesn't work on second/multiple iterations because by
default the query parameter is using the previous query value. The
workaround is to just initialize the query parameter on each call. I'm just
wondering if there's a reason for this or if it's a bug.
Here is some sample code where the list should be iterated twice:
for card in card_list.list_cards_iter(card_filter='all'): print(card.name)
for card in card_list.list_cards_iter(card_filter='all'): print(card.name)
Here is the workaround for actually iterating twice:
for card in card_list.list_cards_iter(card_filter='all', query={}): print(
card.name) for card in card_list.list_cards_iter(card_filter='all',
query={}): print(card.name)
The fix is to change the query parameter to None instead of an empty
dictionary:
https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
Thanks,
Matt
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#307>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABNGYMDRKPUCFM7EHUYOXTRHF5OXANCNFSM4LGYCUZQ>
.
Hey,
The list_cards_iter doesn't work on second/multiple iterations because by default the query parameter is using the previous query value. The workaround is to just initialize the query parameter on each call. I'm just wondering if there's a reason for this or if it's a bug.
Here is some sample code where the list should be iterated twice:
Here is the workaround for actually iterating twice:
The fix is to change the query parameter to None instead of an empty dictionary: https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
Thanks,
Matt
The text was updated successfully, but these errors were encountered: