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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:49:50+00:00 2026-06-16T01:49:50+00:00

Background: I am adding a new function to an existing class which needs to

  • 0

Background:
I am adding a new function to an existing class which needs to return a list of names of constants.

Lets say I have a number of constants in a class

JOHN = 1
SMITH = 4
BEN = 8
...

And I have web service function which returns a list constant values, instead of returning [1,4,8] I would like to return more meaningful data such as ['JOHN', 'SMITH', 'BEN']

What is the efficient way to do it?

  • 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-16T01:49:52+00:00Added an answer on June 16, 2026 at 1:49 am

    You could use map() along with a mapping dictionary.

    arg_map = {1 : 'JOHN', 4 : 'SMITH', 8 : 'BEN'}
    translated_result = map(arg_map.get, result_list)
    

    As mentioned in the comments, a list comprehension would also work here. Note you could make this a generator by replacing the square brackets with parens.

    arg_map = {1 : 'JOHN', 4 : 'SMITH', 8 : 'BEN'}
    translated_result = [arg_map.get(val, '%s NOT MAPPED' % str(val)) for val in result_list]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an asp.NET page which is programmaticaly adding data as new list items
We have a webservice function that runs a list of tasks in the background.
I'm trying to change the background color by adding a new class with another
I have a class which extends SwingWorker<Void, Void> . In it's background thread I
I have implemented background worker class something similar to below sample and I want
I have a form for adding a new username and password to a site.
I have a script that makes barplots, and opens a new window when 6
I have a menu on my page which changes the source of a particular
I know adding static member function is fine, but how about an enum definition?
Coming from a C++ background, I'm used to sticking the const keyword into function

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.