[Tutor] Return key from value

firephreek firephreek at earthlink.net
Fri May 14 12:33:12 EDT 2004

I'm writing a program to help with some database migration issues.  We
have an system running an inventory/sales/invoicing program.  We're
going to open up another part of the program to help automate some of
our cost control/inventory tracking.  Unfortunatly this means inputting
a vendor name/info along with all products that we purchase from said
vendor.  This is on order of several thousand items.  More even...So
we're looking at several months worth of data entry.  I type decently
fast, but not that fast.  But the way the system is, we can't put in the
data, without actually using that portion of the program, which will
conflict with the way we currently use the program.  I (re: my employer)
isn't willing to do that.  So, the idea behind this program is that
it'll read data from my Main System, and allow me to match data from my
incoming products/vendors to what exists in my system, after several
months of this when we've gotten everything together, we can run a
complete list of everything on my external db, and then have 3-4 people
do all the entry in a week.  System goes on with minimal downtime, and
we're only missing maybe 2% of total possible inventory, which is an
acceptable amount that we can make up for as time goes on.  

Bah.  So, I need to build something stupid proof for my fellow
employees.  I'm the only one here who knows his elbow from a cat5 cable
so to speak.  

I thought about duplicating my dictionary set (which will hold k/v to
match vend/# to vend/name so I can search against both.  But because the
set is going to be pretty big (I'll need to cross match item# vs.
item/name) I was looking for the most efficient route, the other option
that occurred is to do a sql query against whatever attribute is
entered, and that may be the route I go with.  We have our own MySQL
server (love! Like python!), is it very different from sqlite?  Both key
and value on all sets will be unique, so I'm not worried about that.
When is 'big' too big?  How far can I push before I see a performance
hit?  I think I'm just going to stop caring about performance and let
them suck it up. Though it hurts to think that...ugh.

That's the long and short of it.  I make no qualms about the fact that
I'm new to some of this, but I'm also not a complete idiot.  I can use a
hammer, I'll make this work one way or another. *grin*


PS: gui is gonna be wxPython, and that's a whole 'nother bag of fish.

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of orbitz at ezabel.com
Sent: Thursday, May 13, 2004 12:38 PM
To: tutor at python.org
Subject: Re: [Tutor] Return key from value

key -> value have a one to one relationship.
value -> key have a 1 to many relatinoship.

You will most likley need to iterate over your dictionary and check if
the value matches, and construct a list of keys.

If you have such a large datastructure, I wonder why you are doing this
in the first place?

On Thu, 13 May 2004 12:13:59 -0700
"firephreek" <firephreek at earthlink.net> wrote:

> I thought there was a method for it, but I can't seem to find it.
> Does anyone know how I can return the matching key from a dictionary
> if I know the value?  I'm working with some very large data 
> structures, and I don't want to have to duplicate them.
> Stryder
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list