Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7636979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:49:29+00:00 2026-05-31T07:49:29+00:00

I got the following python code where printSaved is called when a button is

  • 0

I got the following python code where printSaved is called when a button is clicked (using the wx library and python 2.7.2). But when this happens i got a really strange error

Traceback (most recent call last):
  File "./program.py", line 135, in printSaved
    s = self.readSaved()
TypeError: readSaved() takes no arguments (1 given)

Here is the code

  def readSaved():
    f = codecs.open((os.getenv('HOME') +'/Dokument/savefile.txt') ,'r','utf-8')
    l = f.readlines()
    f.close()
    return l

  def printSaved(self,event):
    s = self.readSaved()
    for l in s:
      print l

I fixed the problem by adding one argument to readSaved(somethingUseless) and everything worked fine. My question is what is passed to readSaved and HOW/WHY? Does this have something to do with the event?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:49:30+00:00Added an answer on May 31, 2026 at 7:49 am

    In Python, the object on which a method is called is always passed in explicitly as an argument. This argument is conventionally called self.

    The correct definition for readSaved() as an instance method should have this as the first line:

    def readSaved(self):
        # ...
    

    If you want it to be a module-level function, you should call it as follows:

    s = readSaved()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code works fine with python.exe but fails with pythonw.exe. I'm using Python
Recently I've spotted a very disturbing issue. I've got the following python code: for
I got following code from net and it looks everything is proper but i'm
i've got this snazzy python code: import subprocess value = subprocess.Popen([php,./php/php_runner.php],stdout=subprocess.PIPE); the problem is,
I tried to run the following code from http://docs.python.org/library/mmap.html import mmap # write a
I've got the following python code that does a date comparison for a list
Consider the two following Python code examples, which achieves the same but with significant
Following this tutorial I got the following error where y = 1; I'm using
I got stuck with the following Python code >>> a = 0xff >>> b
I want to use python in c++ code, but it got an error, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.