'Want input given in 1st class to be accessed by other class
I am very new to python so please ik the code is not so professional and stuff
class VMReader:
def __init__(self, filename):
filename = input("please input the path: ")
self.name = filename
print(self.name)
self.fileHandle = open(self.name, "r")
self.lno = 0 # the current line number
self.IC = 0 # the instruction number
class VMWriter:
def __init__(self, filename):
filename = input("please input the path: ") #(PROBLEM is here)
self.name = filename.split('.')[0]+".asm" # the name of the file to be written to
print("output path = " + self.name)
self.fileHandle = open(self.name, "w")
self.labelCount = 0 # the total number of labels (0 indexed)
self.errCount = 0 # the number of errors found
self.outString = "//" + self.name + "\n" # the string containing all the asm code
I want to access the input which i will be giving in the VMReader class and then the input should be access by VMWriter class ...
As of now i tried inheriting class but still the path did not change it just made a new file in vscode and named it like FileName.py to Filename.asm
but i want it as
the path given by me should be replaced with .asm C:\Users...\StackTest.vm to C:\Users...\StackTest.asm where new file will be created as .asm
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
