How do I get a reference to a KEY value of a dictionary?
tjreedy at udel.edu
Fri Aug 1 02:46:16 CEST 2003
"Andy C" <andychup at yahoo.com> wrote in message
news:645db655.0307311636.71923378 at posting.google.com...
> I am new to python, so please bear with me if I am making some
> conceptual error.
> Basically I want to create a graph with an adjacency list
> representation, but I don't want any of the adjacency lists to have
> duplicate strings when it is avoidable. I have a function
> that adds an edge to the graph. The arguments will be distinct
> they are read from text files. But basically I want to use the
> dictionary as a string pool, and if the argument string equals
> something in the pool already, don't use the argument string, just a
> use a reference to something in the string pool already.
Thinking in terms of 'references' can both help and hinder. (There
have been some long recent discussion.)
Are you familiar with this?
Help on built-in function intern:
intern(string) -> string
``Intern'' the given string. This enters the string in the
table of interned strings whose purpose is to speed up dictionary
Return the string itself or the previously interned string object
More information about the Python-list