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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:35:03+00:00 2026-05-27T10:35:03+00:00

While reloading python modules it’s not hard and assure you that new objects will

  • 0

While reloading python modules it’s not hard and assure you that new objects will use the new code, the problem comes around existing objects.

Is it possible to upgrade existing objects so they will use the new code? We can assume that we know what classes were changed.

Still, it is possible that some additional functionality was added to __init__(), so just copying their dictionaries it not enough. One possible solution I considered was to assure that these objects can be upgraded by doing something like obj = MyClass(obj), meaning that __init__ should be written in such way that it would not break if called several times.

  • 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-27T10:35:03+00:00Added an answer on May 27, 2026 at 10:35 am

    The solution you are considering is perfectly reasonable, but I would suggest adding a static method for creating an updated version of the object instead of adding the additional functionality to __init__(). Consider the following example:

    class Point(object):
        def __init__(x, y):
            self.x = x
            self.y = y
    
        @staticmethod
        def init_from_point(obj):
            return Point(obj.x, obj.y)
    

    With this you could do obj = Point.init_from_point(obj) for your update, without complicating your __init__() at all.

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

Sidebar

Related Questions

I am new to Python. While reading some code, I come across what is
While reading cocoa tutorials i've noticed that some of the tutorials use AppDelegate and
I have an install of python 2.5 that fink placed in /sw/bin/. I use
Thanks in advance for any help. I am new to python, but not particularly
I currently have a Python 2.6 piece of code that runs two loops simultaneously.
I am new in python, and while reading a BeautifulSoup tutorial, I didn't understand
While reading about exception, I will always come across checked exceptions and unchecked exceptions,
While reading a code I came across, the following definition and initialization of a
This question arose while reading the new chapter in the excellent Learn You a
While developing a largeish project (split in several files and folders) in Python with

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.