Hi Skip, Skip Montanaro wrote: > > Greg> Currently, a person can do the following: > > Greg> foo[slice('a','abc')] = some_sequence > > Well, I'll be damned! To wit: [nice implementation cut] > Now, about that motivation... usually I'm not the one to argue against a new feature, but I think this extension to slicing is too much and not consistent enough. When we write x[low:high] = some_sequence then we imply that there is a sequence on the left hand that can be indexed by the implicit ordered set of integers in the range [low, high), and we allow this assignment to change the sequence's length arbitrarily. Speaking of mapping objects, you specify a set of values by an expression of their keys, but you have no way to invent new keys, only deletion applies. Appears a bit twisted to do this to a mapping. A different approach would be to require a mapping object on the right hand. The assignment would have to 1) check that all keys on the right are inside the lice's range 2) delete the entries in that range from the left 3) insert the new keys/values. Indexing a mapping by a slice should return a mapping again. Well, I don't like any of these so much. They make dicts look like something ordered, that rings a bell about too much cheating. Or we could be consequent and provide a sequence protocol for mappings as well, with all that sort-on-demand consequences necessary. But this is not possible since integers can be keys, and it would be undecidable wether we want sequence indexing or mapping indexing. This would only make sense for typed dictionaries, which allow string keys only for instance. I'd say better drop it - chris -- Christian Tismer :^) <mailto:tismer@appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Düppelstr. 31 : *Starship* http://starship.python.net 12163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4