python - Class function not accepting self. variable -


i trying create function in class rotating rotors in enigma machine. however, when try tell rotor use not accept it, demonstrated in code below:

from collections import deque  class rotors:     def __init__(self):         self.a = deque("abcdefghijklmnopqrstuvwxyz")         self.vi = deque("jpgvoumfyqbenhzrdkasxlictw")         self.vii = deque("nzjhgrcxmyswboufaivlpekqdt")                    self.viii = deque("fkqhtlxocbjspdzramewniuygv")          self.rotor_vi = [self.a, self.vi]         self.rotor_vii = [self.a, self.vii]         self.rotor_viii = [self.a, self.viii]         self.rotors = [self.rotor_vi, self.rotor_vii, self.rotor_viii]         self.reflector = deque("fvpjiaoyedrzxwgctkuqsbnmhl")       def rotate_rotor(self, rotor):         rotor.rotate(1)  x = rotors() x.rotate_rotor(self.vi) 

which gives output of:

 traceback (most recent call last):   file "c:\users\aaron\documents\programs\enigma.py", line 20, in <module>     x.rotate_rotor(self.vi) nameerror: name 'self' not defined [finished in 0.1s] 

x.rotate_rotor(self.vi) 

should be:

x.rotate_rotor(x.vi) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -