Name error : name 'honey' is not defined - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Name error : name 'honey' is not defined (/thread-5860.html) |
Name error : name 'honey' is not defined - dila - Oct-25-2017 I have no idea how to get rid of this error. I did read about changing the sys.path but I don't understand how to do it because it's not working at all. Can someone help me fix this error? hashes.py : def encode(self, password, salt, iterations=None): sweetwords = ['road,models,table'] honeywordtweak = 3 sweetwords_len = len(sweetwords) if iterations is None: iterations = self.iterations sweetwords.extend(honey.gen(password, base64, ["passfiles.txt"])) for i in range(0, 3): sweetwords.extend(honeywordtweak.tweak(password, 3)) random.shuffle(sweetwords) hashes = for swd in sweetwords: hashes.append(self.hash(swd, salt, iterations)) self.honeydetector.update_index(salt, sweetwords.index(password)) h = Sweetwords(salt=salt, sweetwords = pickle.dumps(hashes)) h.save() return "%s$%d$%s$%s" %(self.algorithm, iterations, salt, hashes[0]) the error is from that line consists of honey that i bold . honey is a python file that i created to generate my custom password hasher honey is in same directory as hashers.py which is honeywordHasher i already import : from honeywordHasher.honey import HoneywordsGenerator in hashers.py . i cant find where is my mistakes . i have been trying to fix this error for 2 days . this error makes me cannot submit my registration form . RE: Name error : name 'honey' is not defined - Larz60+ - Oct-25-2017 When you re-post your code listing, also include the error traceback. RE: Name error : name 'honey' is not defined - dila - Oct-25-2017 I have no idea how to get rid of this error. I did read about changing the sys.path but I don't understand how to do it because it's not working at all. Can someone help me fix this error? Quote:Traceback: hashers.py : def encode(self, password, salt, iterations=None): sweetwords = ['road,models,table'] honeywordtweak = 3 sweetwords_len = len(sweetwords) if iterations is None: iterations = self.iterations sweetwords.extend(honey.gen(password, base64, ["passfiles.txt"])) for i in range(0, 3): sweetwords.extend(honeywordtweak.tweak(password, 3)) random.shuffle(sweetwords) hashes = for swd in sweetwords: hashes.append(self.hash(swd, salt, iterations)) self.honeydetector.update_index(salt, sweetwords.index(password)) h = Sweetwords(salt=salt, sweetwords = pickle.dumps(hashes)) h.save() return "%s$%d$%s$%s" %(self.algorithm, iterations, salt, hashes[0])honey is a python file that i created to generate my custom password hasher honey is in same directory as hashers.py which is honeywordHasher i already import from honeywordHasher.honey import HoneywordsGeneratorin hashers.py . i cant find where is my mistakes . i have been trying to fix this error for 2 days . this error makes me cannot submit my registration form . RE: Name error : name 'honey' is not defined - Larz60+ - Oct-25-2017 The error message is saying that honey is not defined, and it's not, at least not in the code you are showing. Did you forget to instantiate an import? RE: Name error : name 'honey' is not defined - dila - Oct-31-2017 (Oct-25-2017, 10:34 PM)Larz60+ Wrote: The error message is saying that honey is not defined, and it's not, how to import a file that i created ? i have tried before this and it give me an error RE: Name error : name 'honey' is not defined - wavic - Oct-31-2017 What have you tried? If your file is called honey.py you import it like this: import honey . Without the file extension. Also, you define 'hashes' without a value. It have to be hashes = []
RE: Name error : name 'honey' is not defined - dila - Oct-31-2017 (Oct-31-2017, 08:21 AM)wavic Wrote: What have you tried? If your file is called honey.py you import it like this: i have tried Quote: import honeyand it give me an import error : no module named honey i also tried Quote:import honeywordHasher.honey as honeyand it give me an attribute error : module named 'honeywordHasher.honey' has no attribute 'gen' (honey.py is in honeywordHasher file) the traceback is still in the same line btw |