Dec-20-2019, 04:34 PM
(Dec-20-2019, 04:00 PM)stullis Wrote: If you run it a third time, does it triple? What happens if you wait a couple minutes before running it again? The only way I see it doubling the number of instances rest on line 66. If there are multiple, identical Reservations; it would count duplicate instances. Trying printing the instance_list before the loop and run the script a couple of times.
On a side note, there are some code blocks here that can be simplified. In several places, the following pattern occurs:
if 'KeyName' in instance: key_name = instance['KeyName'] else: key_name = NoneThis effectively does the same thing as dict.get() with a default value included:
key_name = instance.get('KeyName', None)There are others too, but that one stood out the most.
Ok thanks for your response! No, running it a third time, it reports the same number as before. It does that each time it's run. The first time it's run it reports correctly that there are 51 instances. Each time you up arrow and run it again it reports there are 102 (doubled).
I tried printing out the instance_list and I see that it does print out twice. Does that mean that there are two identical reservations? If so how can I deduplicate those results? Thanks for the tip on how to simplify my code I will definitely do that!