I have one basic question,I am declaring xmlfile as global in xml function,can I use it in another subroutine without any issues?does the order of subroutines matter?
def xml():
global xmlfile
file = open('config\\' + productLine + '.xml','r')
xmlfile=file.read()
def table():
parsexml(xmlfile)
The order in which the functions are written does not matter.
The value of
xmlfilewill be determined by the order in which the functions are called.However, it is generally better to avoid reassigning values to globals inside of functions — it makes analyzing the behavior of functions more complicated. It is better to use function arguments and/or return values, (or perhaps use a class and make the variable a class attribute):