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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:59:31+00:00 2026-06-01T00:59:31+00:00

I had a version 1 of a function like: def f(a,b,c): #Some processing return

  • 0

I had a version 1 of a function like:

def f(a,b,c):
    #Some processing
    return some_result

Later, I upgraded it to version 2.

def f(a,b,c):
    #Some processing
    #Some more processing
    return some_result, additional_result

The latter version returns a tuple. Hence all client code using version 1 gets obsolete. Can I get additional_result on demand?

That is you get additional_result only when you ask for it while you continue to get some_result as if nothing changed.

One trick I thought of:

def f(a,b,c, need_additional = False):
    #Some processing
    #Some more processing
    if not need_addional:
        return some_result
    else:
        return some_result, additional_result

Anything better? Or more generic?

  • 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-01T00:59:32+00:00Added an answer on June 1, 2026 at 12:59 am

    I am finally implementing it like:

    def f(a,b,c, v2 = False):
        #Some processing
        #Some more processing
        if not v2:
            return some_result
        else:
            v2_dict = {}
            v2_dict['additional_result'] = additional_result
            v2_dict['...'] = ...
            return some_result, v2_dict
    

    Advantages:

    • Legacy code doesn’t break.
    • No limitation on return values in future edition.
    • Code is manageable.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had tabs with preloaded content like this: $(function () { $('div.tabs ul.tabNavigation a').click(function
I was using mysql++ library and compiling with GCC 3.3.4. That GCC version had
I've got a UITableView with custom tablecells. First I had a version which implemented
I updated my User class, and now whenever someone that had the old version
I had the gmaps4rails gem version 1.4.5 working nicely on my Rails 3.2.2 app.
I had my server working with an earlier version of node.js, npm, and socket.io
My version of oracle is 11g. I had imported my oracle database to a
I had downloaded and installed the 1.6.9 version of SVN from http://subversion.tigris.org/ . After
I've read somewhere that the trunk version of Firefox already had a WebSocket implementation.
I have consistently had IDE problems in Delphi/C++Builder for years, with every version. I

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.