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:
Thanks!
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#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]) |