On Mon, Feb 6, 2012 at 8:24 AM, Edward K. Ream <[email protected]> wrote:

> I am about to convert many of Leo's key-handling dictionaries to
> g.TypedDict objects.  Using TypedDicts will make it impossible to make
> invalid assignments to Leo's crucial key dictionaries.

This has been a great success.  I also defined the g.TypedDictOfLists
class, where the values are lists of a known type.  These classes are
useful for more than type checking:  they have unique names and a dump
method that dumps the dict in an easy-to-read format that includes the
name, and valid types for keys and values.

At present, these dicts are *not* subclasses of {}, which has its
pluses and minuses.  These are quite simple classes, so at present
only the "for key in d.keys()" idiom is supported, the "for key in d"
idiom is not supported.

Plain dicts do have their uses, but for "long-lived" dicts, and dicts
passed around between methods, I am beginning to regard plain dicts as
being as ill-advised as g.Bunches.

Leo's key dictionaries will always be complex, but basing them on the
TypedDict class is a major improvement.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to