So my python script should get a text file and basically translate it using a dictionary, but I'm stuck and can't get it to work, it runs but doesn't do anything effectively.
1st file (which was given):
# -*- coding: utf-8 -*-
from bead import Ford
szotar = {"The" : "A", "sun": "nap", "shining" : "süt", "wind" : "szél", "not" : "nem", "blowing" : "fúj"}
fd = Ford(szotar)
fd.fordit("teszt.txt", "kimenet.txt")
And my attempt on that Ford class:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Ford:
def __init__ (self, values = dict(), keys = dict()):
self.values = values
self.keys = keys
def fordit(self, inFile, outFile):
self.inFile = inFile
self.outFile = outFile
try:
with open("teszt.txt", 'r') as inFile:
text = inFile.read()
except:
print "Nincs input file!"
for key in dict().iterkeys():
text.replace(key,dict()[key])
outFile = open("kimenet.txt", "w")
outFile.write(text)
outFile.close()
I am new to python, so every bit of advice and help is greatly appreciated.