Python Forum
bksp() requires no arguments (one given)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bksp() requires no arguments (one given)
#1
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?
Reply
#2
Quote:bksp() takes no arguments (1 given)

Quote:   def bksp():

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

You meant to do

def bksp(self):
Recommended Tutorials:
Reply
#3
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
Reply
#4
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  hypothesis 6.46.2 requires python3.7 or later Anldra12 6 1,610 Jun-22-2022, 11:05 AM
Last Post: Anldra12
  Using python to execute app or cmd that requires admin credentials thewolf 0 2,101 Mar-05-2021, 08:15 PM
Last Post: thewolf
  Making .exe file that requires access to text and html files ClassicalSoul 0 1,574 Apr-23-2020, 05:03 PM
Last Post: ClassicalSoul
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,855 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020