Jun-19-2024, 07:03 AM
(This post was last modified: Jun-19-2024, 07:03 AM by Gribouillis.)
(Jun-18-2024, 11:37 PM)Curbie Wrote: stupid question, are both 'table' and 'res' global variables, if not what makes a global variable?Yes they are global variables because they are defined at module level and not in the body of a function. In the following code
spam = 25 def eggs(): ham = 36
spam
is a global variable and ham
is a local variable of function eggs()
. When function eggs() is called, ham is destroyed at function exit. Spam is never destroyed, unless we write at module leveldel spamWe could also do
spam = "...some memory intensive data..." spam = None # does not destroy the name 'spam' but destroys the value at which it points.
« We can solve any problem by introducing an extra level of indirection »