Python Forum
Independent Secondary index for dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Independent Secondary index for dictionary
#7
(Dec-20-2018, 07:02 PM)Larz60+ Wrote: The problem with this is that there's two separate dictionaries needed, I'd like it to be self contained

Well, if you put them both in another dict (company_data = {'values': company, 'aliases': company_aliases}), your find_company function is simpler:

def find_company(key):
    return company_data['values'][company_data['aliases'].get(key, key)]
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Independent Secondary index for dictionary - by ichabod801 - Dec-20-2018, 07:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple user defined plots with secondary axes using for loop maltp 1 1,530 Apr-30-2022, 10:19 AM
Last Post: maltp
  Making a plot with secondary y-axis bigger snkm 0 1,164 Feb-10-2022, 09:40 AM
Last Post: snkm
  Loop independent of excecution time of a script Forelli 8 3,930 Feb-02-2020, 10:49 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020