Nov-30-2019, 05:27 AM
Note: This is in context of a self contained module, having some functions which are not meant to be called by any other module.
As per recommended practice, use of module level variables in an assignment statement within a function, needing prior declaration as global. is to be avoided.
Could it be presumed that there would be no objection to use of other such variables within the function when manipulation of their values is not involved and global declaration is not needed?
In case of object variables serving as pointers to lists, dictionaries etc, the base object does get affected, even if the reference is passed to the function under a different name. As a result, the effect is global, even without any global declaration.
Under the circumstances, your views are requested whether there could be any grounds against:
(a) Passing object variable reference as function argument, without changing the name of such variables.
OR
(b) Using the module level object variable name without explicitly passing it to the function as an argument.
As per recommended practice, use of module level variables in an assignment statement within a function, needing prior declaration as global. is to be avoided.
Could it be presumed that there would be no objection to use of other such variables within the function when manipulation of their values is not involved and global declaration is not needed?
In case of object variables serving as pointers to lists, dictionaries etc, the base object does get affected, even if the reference is passed to the function under a different name. As a result, the effect is global, even without any global declaration.
Under the circumstances, your views are requested whether there could be any grounds against:
(a) Passing object variable reference as function argument, without changing the name of such variables.
OR
(b) Using the module level object variable name without explicitly passing it to the function as an argument.
A.D.Tejpal