bksp() requires no arguments (one given) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: bksp() requires no arguments (one given) (/thread-676.html) |
bksp() requires no arguments (one given) - gdog1102 - Oct-28-2016 Here is some code for my text editor (in progress) print 'WELCOME TO CHARPY V2' import os #os detection/import msvcrt try: import msvcrt except ImportError: print 'ERROR: FAILED TO IMPORT MSVCRT. ARE YOU USING MAC OS X OR UNIX/LINUX?' print 'IF SO, PLEASE USE WINDOWS FOR CHARPY V2' quit() #defining class for documents class doc(object): def __init__(self): #this is the actual text self.text = list() self.name = raw_input('NAME YOUR NEW DOCUMENT') def bksp(): length = len(self.text) length = length - 1 lob = self.text[length] self.text.remove[lob] def edit(self): self.isedit = True while self.isedit: char = msvcrt.getch() if char not in ('<','`'): self.text.append(char) elif char == '<': self.bksp() elif char == '`': #stop editing self.isedit = False os.system('CLS') print self.text x = doc() x.edit()For some strange reason, if I press '<', i get the error bksp() takes no arguments (1 given) What gives? RE: bksp() requires no arguments (one given) - metulburr - Oct-28-2016 Quote:bksp() takes no arguments (1 given) Quote: def bksp(): Quote:elif char == '<': self.bksp() You meant to do def bksp(self): RE: bksp() requires no arguments (one given) - Larz60+ - Oct-28-2016 First you can use 'platform.system()' to tell which operating system is being used. the doc string is Quote:Returns the system/OS name, e.g. 'Linux', 'Windows', or 'Java'. An empty string is returned if the value cannot be determined. As far as your '<' problem, see http://stackoverflow.com/questions/14796323/input-using-backspace-and-arrow-keys RE: bksp() requires no arguments (one given) - gdog1102 - Oct-28-2016 (Oct-28-2016, 04:05 AM)metulburr Wrote:Quote:bksp() takes no arguments (1 given) I should probably proofread my code before asking about it sorry. |