Python Forum
Python function returns inconsistent results
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python function returns inconsistent results
#2
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 = None
This 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.
Reply


Messages In This Thread
RE: Python function returns inconsistent results - by stullis - Dec-20-2019, 04:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Bug New to coding, Using the zip() function to create Diret and getting weird results Shagamatula 6 1,504 Apr-09-2023, 02:35 PM
Last Post: Shagamatula
  Read csv file with inconsistent delimiter gracenz 2 1,246 Mar-27-2023, 08:59 PM
Last Post: deanhystad
  Inconsistent loop iteration behavior JonWayn 2 1,029 Dec-10-2022, 06:49 AM
Last Post: JonWayn
  function returns dataframe as list harum 2 1,466 Aug-13-2022, 08:27 PM
Last Post: rob101
  ValueError: Found input variables with inconsistent numbers of samples saoko 0 2,510 Jun-16-2022, 06:59 PM
Last Post: saoko
  function accepts infinite parameters and returns a graph with those values edencthompson 0 887 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  Loop Dict with inconsistent Keys Personne 1 1,635 Feb-05-2022, 03:19 AM
Last Post: Larz60+
  Inconsistent counting / timing with threading rantwhy 1 1,791 Nov-24-2021, 04:04 AM
Last Post: deanhystad
  Inconsistent behaviour in output - web scraping Steve 6 2,627 Sep-20-2021, 01:54 AM
Last Post: Larz60+
  Found input variables with inconsistent numbers of samples: [1000, 200] jenya56 2 2,945 Sep-15-2021, 12:48 PM
Last Post: jenya56

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020