background preloader

Rcaley

Facebook Twitter

[Tutor] creating text files.

Materials

Python Dict and File - Google's Python Class - Google Code. Dict Hash Table Looking up or setting a value in a dict uses square brackets, e.g. dict['foo'] looks up the value under the key 'foo'.

Python Dict and File - Google's Python Class - Google Code

Strings, numbers, and tuples work as keys, and any type can be a value. Other types may or may not work correctly as keys (strings and tuples work cleanly since they are immutable). Looking up a value which is not in the dict throws a KeyError -- use "in" to check if the key is in the dict, or use dict.get(key) which returns the value or None if the key is not present (or get(key, not-found) allows you to specify what value to return in the not-found case).

Networks

Miscellaneous. Software. Chemical Engineering. Programming. Mathematics. Information Sources. Alternative energy. Pearltrees videos. Help.