72Re: [python-iter] Colon syntax: We barely knew thee...
- Mar 3, 2001From: <qrczak@...>
>You can think about that in your own terms :)
> 1. xkeys(), xitems().
> 2. keys, items.
> 3. keys(), items().
> Why 1: Doesn't change existing methods or break any existing code.
> Doesn't require any magic to work - easy to understand.
> Consistent with xrange() and xreadlines().
> Why not 1: Introduces an unnecessary duplication of names only to
> enable good performance. A programmer should not have to
> worry whether he should use keys or xkeys, because their
> meaning is essentially the same.
> Why 2: A single attribute can be used as either iterator or list
> producer, with backward-compatible syntax for the latter.
> Why not 2: Attribute syntax plays the role of a method only because of
> backward compatibility. Classes must implement this using
> __getattr__ because it's really a stateful method call.
> Doesn't scale to places when an argument is needed or to
> module-scope functions (e.g. range).
dict.keys = stateless lazy list
dict.keys() = dict.keys.__call__() - to produce old fashion list
- << Previous post in topic