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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:38:15+00:00 2026-06-13T14:38:15+00:00

I have code running on a server with namedtuples: Event = namedtuple(Event, [‘attr1’, ‘attr2’,

  • 0

I have code running on a server with namedtuples:

Event = namedtuple("Event", ['attr1', 'attr2', 'attr3'])

The server is getting events from other servers, coming out of a queue.

I want to add a new feature to my code which needs a new attribute in the namedtuple. Is there a good way to do this and keep backwards compatibility? That is, I can stop and start the server, and change the code to:

Event = namedtuple("Event", ['attr1', 'attr2', 'attr3', 'attr4'])

But in the meantime there will be Events with the old signature queued up.

Anyone done this before?

  • 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-13T14:38:16+00:00Added an answer on June 13, 2026 at 2:38 pm

    It would work as it is, only problem can occur is in your code when you are using the newly added attribute e.g.

    from collections import namedtuple
    
    Event1 = namedtuple("Event", ['attr1', 'attr2', 'attr3', 'attr4'])
    Event2 = namedtuple("Event", ['attr1', 'attr2', 'attr3', 'attr4', 'attr5'])
    
    def handle_event(event):
        print event.attr5
    
    handle_event(Event2(1,2,3,4,5))
    handle_event(Event1(1,2,3,4))
    

    You will get error AttributeError: 'Event' object has no attribute 'attr5' so if you taken care of such thing in backward-compatible way, like checking if attr5 is there, it should work

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

Sidebar

Related Questions

Iam running WAMP server and just enabled php_memcache extension and have tried the code
Suppose I have some PHP code running inside a web server, for example, running
I have a copy of a code running on the production server, and I
I have a php code running on my server that i call my web
On server side I have this code which running in new thread static void
I have an apache httpd server running python code using django framework and mod_wsgi.
I have following code, running on Unix server (WAS 5.1), it's a test environment
I have the following code running on my website. I call it from a
I have code running in an iPhone application I am developing. Basically, the code
I have this code running in my onDestroy function: @Override protected void onDestroy() {

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.