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 7521011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:09:52+00:00 2026-05-30T02:09:52+00:00

I have a save function within my Python program which looks like this: def

  • 0

I have a save function within my Python program which looks like this:

def Save(n):
    print("S3")
    global BF
    global WF
    global PBList
    global PWList
    print(n)
    File = open("C:\KingsCapture\Saves\\" + n + "\BF.txt", "w")
    pickle.dump(BF, File)
    File = open("C:\KingsCapture\Saves\\" + n + "\WF.txt", "w")
    pickle.dump(WF, File)
    File = open("C:\KingsCapture\Saves\\" + n + "\PBList.txt", "w")
    pickle.dump(PBList, File)
    File = open("C:\KingsCapture\Saves\\" + n + "\PWList.txt", "w")
    pickle.dump(PWList, File)

Here, n is “1”.

I get an error looking like this:

  File "C:/Python27/KingsCapture.py", line 519, in Save
    File = open("C:\KingsCapture\Saves\\" + n + "\BF.txt", "w")
TypeError: an integer is required

Upon doing the same loading within the shell, I get no errors:

>>> File = open("C:\KingsCapture\Test\List.txt", "r")
>>> File = open("C:\KingsCapture\Test\List.txt", "w")
>>> n = "1"
>>> File = open("C:\KingsCapture\Saves\\" + n + "\BF.txt", "r")
>>> File = open("C:\KingsCapture\Saves\\" + n + "\BF.txt", "w")

Why is this having a problem?

  • 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-30T02:09:54+00:00Added an answer on May 30, 2026 at 2:09 am

    You probably did a star import from the os module:

    >>> open("test.dat","w")
    <open file 'test.dat', mode 'w' at 0x1004b20c0>
    >>> from os import *
    >>> open("test.dat","w")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: an integer is required
    

    so you’re using the wrong open function. (I suppose you could’ve simply done from os import open, but that’s less likely.) In general this import style should be avoided, as should use of global, where practical.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple unsubscribe function in my Unsubscribed controller. if ($this->Unsubscribe->save($this->data['Unsubscribes'])) { //
i have the following function to override the default save function in a model
I have the following code: <script type=text/javascript> $(document).ready(function() { $(#Save).click(function() { $.post(url, { data:
I have code that uses Win API function RegSaveKeyEx to save registry entries to
I have a btnSave_Click() function in my code-behind. If a user clicks the save
We have repositories which have a Save method. They also throw a Created event
Is it possible to have Python save the .pyc files to a separate folder
I have two functions, one which parses all the arguments sent to the function
I have a set of classes something like this: abstract class CollectionAbs implements Iterator
I have an asp.net page with a save button within an updatepanel and contenttemplate.

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.