Python Forum

Full Version: bksp() requires no arguments (one given)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
Huh
What gives?
Quote:bksp() takes no arguments (1 given)

Quote:   def bksp():

Quote:
            elif char == '<':
                self.bksp()

You meant to do

def bksp(self):
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/14796...arrow-keys
(Oct-28-2016, 04:05 AM)metulburr Wrote: [ -> ]
Quote:bksp() takes no arguments (1 given)

Quote:   def bksp():

Quote:
            elif char == '<':
                self.bksp()

You meant to do

def bksp(self):

I should probably proofread my code before asking about it  Doh sorry.