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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:34:57+00:00 2026-06-17T11:34:57+00:00

In an interactive Python session, I sometimes do dumb things like plot.ylimits = (0,100)

  • 0

In an interactive Python session, I sometimes do dumb things like

plot.ylimits = (0,100)

where plot is an instance of some Plot class, and ylimits is a method for it. I should have tapped in this:

plot.ylimits(0,100)

The way Python works, the plot object now has a new member named ylimits which hold a tuple as its value, and the method, the executable subroutine originally provided by the Plot class, which used to be invoked with ylimits(…) is gone. Maybe somewhere in my mind I’m thinking ylimits is a property, and assigning to it invokes some hidden setter method, as is done in some other languages.

How can I get back that method? Just how can a repair my plot object, while staying in the interactive session where I have many other variables, functions, etc. in use?

I find that reload(theplotmodule) doesn’t do the job. I have ruined a specific instance of Plot; refreshing the definition of the Plot class and other stuff doesn’t help.

I’m using Python 2.7

  • 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-17T11:34:58+00:00Added an answer on June 17, 2026 at 11:34 am

    A simple way is to do del plot.ylimits. In general, methods are defined on the class, not the instance. Python just looks attributes up every time you try to access them, and when it doesn’t find them on the instance, it goes to the class. When you did plot.ylimits=(0,100), you created a new instance attribute, so Python stops there and doesn’t look for the class attribute, even though it still exists. del plot.ylimits will delete the instance attribute, and now plot.ylimits will again access the method by looking it up on the class.

    Note, though, that this only works when the thing you overwrote was originally on the class, not the instance. If you actually have data stored on the instance, and you overwrite it, it’s gone forever.

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

Sidebar

Related Questions

I would like to add some interactive capability to a python CLI application I've
In shells like the interactive python shell, you can usually use the arrow keys
In interactive python I'd like to import a module that is in, say, C:\Modules\Module1\module.py
I'd like to extend the Python interactive shell to allow execution of non-python specific
Is there any way to make a python program start an interactive debugger, like
When I am in an interactive python session (usually IPython), the following commands: from
Possible Duplicate: How to save a Python interactive session? Is it possible, and if
I have a completely non-interactive python program that takes some command-line options and input
What are the consequences of ending an interactive Python session without first closing an
In the Python interactive interpreter: I am importing a module that contains a class.

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.