I would like to make a class for taking inputs from the user and then return all these inputs for later process. An example, after taking inputs from the users (filenames) then the program stores the names in list. The program later will load the list and perform the process based on each filename for one process.
More explanations:
- User inputs 3 filenames, 3 output filenames, Name of item within file, Json filenames.
- I will create a class(Reason I create it so that it looks nice and wont be too messy since it doesnt contain in a function or class) to take these inputs and then return it.
- Program reads the input one by one and perform the process in one script.
My code:
class ReturnAllInput():
def __init__(self,Morefilenames, Yourfilename, YourJsonName, Outputname, NameWithin):
self.Morefilenames = Morefilenames
self.Yourfilename = Yourfilename
self.YourJsonName = YourJsonName
self.Outputname = Outputname
self.NameWithin = NameWithin
def allInput():
Morefilenames = []
while True:
a = input("Please enter your Morefilenames " )
if a == "Complete":
break
else:
Morefilenames .append(a)
# user typed complete
print("You entered {} Morefilenames ".format(len(Morefilenames )))
for n in Morefilenames :
print('{}.txt'.format(n))
Yourfilename= input("Yourfilename")
YourJsonName= input("YourJsonName")
Outputname= input("Outputname")
NameWithin= input("NameWithin")
return ReturnAllInput(Morefilenames , Yourfilename, YourJsonName, Outputname, NameWithin)
for l in allinput(): #this is the section I do not know how to change it so that I could loop my return values of Morefilenames)
if __name__ == "__main__":
If my codes arent good enough, please do let me know so that I could improve more. I am still a beginner and would like to learn more. Thank you in advance.