Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resetting Global Variables?
#6
Think of a function as a calculator. You give it some info, it gives you some response. If you give it "4+3", it will ALWAYS give you "7" as a response. It won't look up what 7 currently means, and sometimes return "8", it'll always give you the same response for a given argument.

It's getting hard for you to track down errors, because your functions aren't black boxes. They either don't take arguments, or use those arguments to get a part of an external whole.

Let's take FindFnum() for example:
def FindFnum():
    CustomerSaleID = CustomerSaleOBJID()
    Fnum = str(CustomerIndex[CustomerSaleID][3])
    return Fnum
What's a CustomerIndex? What does CustomerSaleOBJID return when you don't pass it anything? Ideally, CustomerSaleOBJID would return every single customer sales record you have, for every single customer you've ever done business with, because you didn't narrow it down at all. But it doesn't. It returns whatever the magic number InxLoc is, from whatever the mysterious LoadedSales is.

From these snippets, it looks like you're not really using functions at all. It looks like you're using a dict to hold some value, and then doing something with it, using functions as a sort of nickname to parts of the dict.
Reply


Messages In This Thread
Resetting Global Variables? - by WuchaDoin - Sep-28-2018, 03:12 PM
RE: Resetting Global Variables? - by micseydel - Sep-28-2018, 04:31 PM
RE: Resetting Global Variables? - by WuchaDoin - Sep-28-2018, 04:35 PM
RE: Resetting Global Variables? - by ichabod801 - Sep-28-2018, 05:14 PM
RE: Resetting Global Variables? - by WuchaDoin - Sep-28-2018, 05:20 PM
RE: Resetting Global Variables? - by nilamo - Sep-28-2018, 06:41 PM
RE: Resetting Global Variables? - by WuchaDoin - Sep-28-2018, 06:59 PM
RE: Resetting Global Variables? - by nilamo - Sep-28-2018, 07:09 PM
RE: Resetting Global Variables? - by WuchaDoin - Sep-28-2018, 07:50 PM
RE: Resetting Global Variables? - by ichabod801 - Sep-28-2018, 08:34 PM
RE: Resetting Global Variables? - by WuchaDoin - Sep-28-2018, 08:41 PM
RE: Resetting Global Variables? - by volcano63 - Sep-28-2018, 08:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand global variables 357mag 5 1,237 May-12-2023, 04:16 PM
Last Post: deanhystad
  Global variables or local accessible caslor 4 1,125 Jan-27-2023, 05:32 PM
Last Post: caslor
  global variables HeinKurz 3 1,237 Jan-17-2023, 06:58 PM
Last Post: HeinKurz
  Clarity on global variables JonWayn 2 1,015 Nov-26-2022, 12:10 PM
Last Post: JonWayn
  resetting an iterator to full Skaperen 7 7,263 Feb-20-2022, 11:11 PM
Last Post: Skaperen
  variables vcnt, ocnt, and mcnt adding previous values and not resetting to 0 archanut 2 2,009 Feb-12-2021, 06:56 PM
Last Post: deanhystad
  Global variables not working hobbyist 9 4,885 Jan-16-2021, 03:17 PM
Last Post: jefsummers
  Global vs. Local Variables Davy_Jones_XIV 4 2,735 Jan-06-2021, 10:22 PM
Last Post: Davy_Jones_XIV
  Global - local variables Motorhomer14 11 4,411 Dec-17-2020, 06:40 PM
Last Post: Motorhomer14
  Question regarding local and global variables donmerch 12 5,278 Apr-12-2020, 03:58 PM
Last Post: TomToad

Forum Jump:

User Panel Messages

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