Hi,
I wrote two Python programs. One program has a class definition and other program importing that class to access its attributes and methods. In both the programs I am importing sys in-built library and using it. Is there any way to import sys library in one program and use it in other program without importing?
Code is here:
I wrote two Python programs. One program has a class definition and other program importing that class to access its attributes and methods. In both the programs I am importing sys in-built library and using it. Is there any way to import sys library in one program and use it in other program without importing?
Code is here:
#Program: program_1.py
import sys
class xmlFile:
def sendXML(self, xmlFile):
try:
print("Processing XML file %s..." %xmlFile)
except FileNotFoundError:
print(os.path.basename(sys.argv[0])
+ "->" + self.__class__.__name__
+ "::"
+ sys._getframe().f_code.co_name
+ "(): File "
+ xmlFile
+ " does not exists!")
exit(-2)
#Proram: program_2.py
import sys
import os.path
from program_1 import xmlFile
if (len(sys.argv) <= 1):
print("usage: "+(os.path.basename(sys.argv[0]))+" <xml file>")
exit
xmlFl = xmlFile()
dataList = xmlFl.sendXML(sys.argv[fl])Thanks!
