How to retrieve an object from a Python Dictionary
<p>I'm trying to retrieve an object that I've placed into a dictionary, but every time I try to retrieve it I receive an error:</p>

<pre><code>  class CSVEntry:
    lat = []
    lon = []
    count = 0

  # Create dictionary for tracking inputs
  dict = defaultdict(list)

  # Lookup the zipcode (returns an integer value)
  zipcode = ConvertLatLonToZip(row[latCol], row[lonCol])

  # If the zipcode is already in the dictionary, update it with the new count
  if zipcode in dict:
    oldEntry = dict[zipcode]
    oldEntry.lat.append(row[latCol])
    oldEntry.lon.append(row[lonCol])
    oldEntry.count = dict[zipcode].count + 1

  # Otherwise, make a new entry
  else:
    entry = CSVEntry()
    entry.lat.append(row[latCol])
    entry.lon.append(row[lonCol])
    entry.count = 1

    # Hash on the zipcode
    dict[zipcode].append(entry)
</code></pre>

<p>It has no problem inserting entries into the dictionary, but as soon as it finds a duplicate, it fails with this error:</p>

<pre><code>Traceback (most recent call last):
  File "ParseCSV.py", line 125, in &lt;module&gt;
    oldEntry.lat.append(row[latCol])
AttributeError: 'list' object has no attribute 'lat'
</code></pre>

<p>I apologize if this is a duplicate or a ridiculously simple question. I'm a beginner to Python and I searched for a long while before deciding to post.</p>

<p>EDIT: Added the definition of dict</p>
