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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:33:36+00:00 2026-06-11T20:33:36+00:00

I have a simple game I’m working on in py 2.7 that uses pickle

  • 0

I have a simple game I’m working on in py 2.7 that uses pickle to read and write save files.

I’m self-taught, and I just started learning like a week ago. I usually can find solutions to my problems online, but this one is taking way too long for what it would accomplish, so I’m asking for a little help.

The problem is that I have this try/except

        f = file("VTSave2.pkl", "rb")
        try:
            game = load(f)
            print "Game has been loaded from save 2."
        except IOError:
            pass

in a save-reading thing. VTSave2.pkl does not currently exist- I’m using this fact to test the try/except.

While I do get the appropriate error, [Errno 2], the IOError passer doesn’t do squat. Instead of “load cancelled” I get a quit program and a traceback.

Am I making any dumb mistakes? Anything I should know? Any more information I should give? Thanks a bunch for your time!

Edit: Thank you! It works now. Since I’ve had someone try to “correct” the formatting of the code, and it ended up breaking my prog when I adopted it, I’ve taken out all code no longer relevant to the question to try to avoid baiting erroneous cleanup. Thank you!

proper working code:

    try:
        f = open("VTSave2.pkl", "rb")
        game = load(f)
        print "Game has been loaded from save 2."
    except IOError:
        pass
  • 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-06-11T20:33:37+00:00Added an answer on June 11, 2026 at 8:33 pm

    This is raising the exception

    f = file("VTSave2.pkl", "rb")
    

    you need to move it after the try:

    If you read the traceback carefully, you should see that the exception is raised at that line number

    Aside: file() is deprecated. You should use f = open("VTSave2.pkl", "rb").

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

Sidebar

Related Questions

I have a simple game that uses a 3D grid representation, something like: Blocks
ok well i have a simple game that uses really high of memory and
I have a simple JavaScript game that sends a score to PHP by adding
I have a very simple HTML5 game that works as expected from a regular
Say I have simple program that emulates a board game with a number of
I'm working on a simple board game in qt, and i have some problem
I have a simple game that is in progress. As of right now all
I have a somewhat simple game that I'm making and now that I'm testing
i have a simple xna game that i want to port that to silverlight,
I have just started trying to make a simple game with XNA 3.1 to

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.