Re: List index method for complex list item types?



Mike,

I'm trying to figure out dictionaries using the documentation. Clicking
on "dictionary type" takes me to "2.3.8 Mapping Types -- classdict". Is
that the documentation for the dictionary type? If so, I do not see an
"append" or "add" or "insert" method defined in the list of methods on
that page.

Here's what they list:

Operation Result Notes
len(a) the number of items in a
a[k] the item of a with key k (1)
a[k] = v set a[k] to v
del a[k] remove a[k] from a (1)
a.clear() remove all items from a
a.copy() a (shallow) copy of a
a.has_key(k) True if a has a key k, else False
k in a Equivalent to a.has_key(k) (2)
k not in a Equivalent to not a.has_key(k) (2)
a.items() a copy of a's list of (key, value) pairs (3)
a.keys() a copy of a's list of keys (3)
a.update([b]) updates (and overwrites) key/value pairs from b (9)
a.fromkeys(seq[, value]) Creates a new dictionary with keys from seq
and values set to value (7)
a.values() a copy of a's list of values (3)
a.get(k[, x]) a[k] if k in a, else x (4)
a.setdefault(k[, x]) a[k] if k in a, else x (also setting it) (5)
a.pop(k[, x]) a[k] if k in a, else x (and remove k) (8)
a.popitem() remove and return an arbitrary (key, value) pair (6)
a.iteritems() return an iterator over (key, value) pairs (2), (3)
a.iterkeys() return an iterator over the mapping's keys (2), (3)
a.itervalues() return an iterator over the mapping's values (

.



Relevant Pages

  • Re: Creating a new PoolDictionary
    ... We, too, are wrestling with accessor methods. ... dictionaries to constants, then perhaps there's no need for complex ... I would feel obliged to do something about the documentation for ... few constants defined then I am quite happy defining them as methods ...
    (comp.lang.smalltalk.dolphin)
  • Re: List index method for complex list item types?
    ... > I'm trying to figure out dictionaries using the documentation. ... > that the documentation for the dictionary type? ... > a.itervaluesreturn an iterator over the mapping's values ( ...
    (comp.lang.python)
  • Re: TIP#308: Last serial column value generated
    ... documentation. ... how dictionaries represent NULL values. ... SQL queries produce values in the correct ordinal position, ...
    (comp.lang.tcl)
  • Re: "Horaltic"
    ... If by documentation you mean a dictionary entry, ... If you don't mind more questions, where is that common usage, aside ... "Horaltic" isn't in American dictionaries either. ... "certain summer fruits" are horal ...
    (rec.birds)
  • Re: Dict sharing vs. duplication
    ... array, not a dict. ... Dictionaries are values. ... the iterator, just in case the arbitrary script needs write access. ...
    (comp.lang.tcl)