Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105521
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "Marco S." <mail.python.org@marco.sulla.e4ward.com> |
| Newsgroups | comp.lang.python |
| Subject | Suggestion: make sequence and map interfaces more similar |
| Date | Tue, 22 Mar 2016 20:54:40 +0100 |
| Lines | 19 |
| Sender | forwardedby@e4ward.com |
| Message-ID | <mailman.34.1458721359.2244.python-list@python.org> (permalink) |
| Reply-To | mail.python.org@marco.sulla.e4ward.com |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de 6CqgdwyJX6hVi0EDuM1IrQqv6DWM9OZOAKj4junYrXYw== |
| Return-Path | <11375.gmail.com@bounce.e4ward.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'method,': 0.07; 'only,': 0.07; 'reason,': 0.07; 'type,': 0.07; 'dict': 0.09; 'untouched.': 0.09; 'suggest': 0.15; '"d"': 0.16; 'iterable': 0.16; 'iterates': 0.16; 'keys.': 0.16; 'parameter,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:interfaces': 0.16; 'subject:make': 0.16; 'useless': 0.16; 'input': 0.18; 'keys': 0.22; 'parameter': 0.22; 'simpler': 0.22; 'ease': 0.23; 'message- id:@mail.gmail.com': 0.27; 'sequence': 0.27; 'values': 0.28; 'types.': 0.29; 'code': 0.30; 'noticed': 0.32; 'received:google.com': 0.35; 'header:Received:8': 0.35; 'could': 0.35; 'generic': 0.35; 'maps': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'seem': 0.37; 'creation': 0.38; 'received:209': 0.38; 'does': 0.39; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.40; 'default': 0.61; 'subject:more': 0.61; 'introduction': 0.63; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'received:23': 0.84; 'gaps': 0.93 |
| Authentication-Results | dfw.e4ward.com (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=e4ward.com |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=e4ward.com; h= reply-to:content-type:content-type:subject:subject:message-id :date:date:from:from:mime-version; s=mail; t=1458676527; x= 1458762928; bh=WM8dIasf0QHedIBnb7srx/r1Yl5cmBQKfAWHu1j9w9w=; b=c VWqwn1M2kKF+9LlIOqvsk4dxLRM8w5CgU3Wx9ch5vfLBAAO/RAGX6zrV25JB7xb1 3TViFd6pW4VSz2wmwdqJTz1HvRieNK+1boLcDawwrOASk5RTzNWInvttr6DK1M6M OMgpl7NtIH3C6o66+7FcVwDC/RZ0UEP1JasXfA+0pk= |
| Authentication-Results | dfw.e4ward.com (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=gmail.com |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=WM8dIasf0QHedIBnb7srx/r1Yl5cmBQKfAWHu1j9w9w=; b=gH8YPFdL+ydmSevyXm3iDPg/KwdR3E2EN5h2J6T5ueAEXI4p2kHga4giX3W/T6GrkZ nsptIwo7CjiJvYDoCA5gGNIoUUP3t2T2y8io6waSXK0jwsmJbCSKvCHs1W3ODEM3QjSp jArhNS4okPofsnZI0NdL2b+dcZhp1g+W+Mp38nrQsh2bF73+itALASy84W4TuYQ8fztW 9lWFIExuJPCg/tHtP0hIGVDIBfxZ/Mb1/Lz3C5TrphBqQSd97tQmFPOz0QVFcjEv77sW Li56HKYOxJQHX66v0ozkYbXqFUQtRJEp+CU0Hl7IiRWcVDyiXbpaMlaeQk80vCItV4fW SZMg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=WM8dIasf0QHedIBnb7srx/r1Yl5cmBQKfAWHu1j9w9w=; b=lUAyK+1Kat8/vJbRRW1MvidyGhpXNkxAkQJaqS2I+PmKzSYiFxPSJsEc9kROl7A4Aj jiHSjzwCeMjE5V/fyHWXMRnbfJUegjqscx2vBak4LeEA9o9KfRRTIglaDlFyHj3cX+TK 5l/TbAuXwp36JAorWav1sqq0V+tXpF7nAmdikgLOsbMEMJiyYFGShVTzfpDkSJMIYNIB IVzT7D4ch0Iu4D+LPpcMhg6MvdMJw3NtWPumVxyvvsA5V4e5BLc6UqxVLXYfEJvUbnG9 rChu/3/XGh/4rXaEOkIXiP7P1wgULgxn0gPmp55LtwRUfauf2AMyGV13Y0bBqo3+Dy1i qauQ== |
| X-Gm-Message-State | AD7BkJJClv5eNQloF6l77QsG4Chom+cx809HNpIeSzWvmlai2jfA+90Ok0xEkb9egUlQh76KY2KkbHVg29n6Qw== |
| X-Received | by 10.60.160.97 with SMTP id xj1mr21203973oeb.80.1458676519478; Tue, 22 Mar 2016 12:55:19 -0700 (PDT) |
| X-e4ward-RCPT | python-list.python.org-mail.python.org.marco.sulla.e4ward.com@ftcw4rx8877.reply.e4ward.com |
| X-e4ward-x | . |
| X-Mailman-Approved-At | Wed, 23 Mar 2016 04:22:39 -0400 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:105521 |
Show key headers only | View raw
I noticed that the sequence types does not have these methods that the map types has: get(), items(), keys(), values(). It could seem useless to have them for sequences, but I think it will ease the creation of functions and methods that allow you to input a generic iterable as parameter, but needs to use one of these methods in case the parameter is a map. In one word, it will facilitate duck typing. For the same reason, I would suggest the introduction of a new map type, vdict, a dict that by default iterates over values instead over keys. So a vdict object "d" wiil have iter(d) == iter(d.values()), and should also have a count() method, like sequence types. Indeed sequences are, in my humble opinion, a specialized case of maps, when keys are numeric only, are always contiguous without gaps and start from 0. This way we will have a simpler way to let people to use sequences or maps indifferently, and let the code untouched.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Suggestion: make sequence and map interfaces more similar "Marco S." <mail.python.org@marco.sulla.e4ward.com> - 2016-03-22 20:54 +0100
Re: Suggestion: make sequence and map interfaces more similar Steven D'Aprano <steve@pearwood.info> - 2016-03-23 22:26 +1100
Re: Suggestion: make sequence and map interfaces more similar Marco Sulla <marcosullaroma@gmail.com> - 2016-03-26 01:18 +0100
Re: Suggestion: make sequence and map interfaces more similar Steven D'Aprano <steve@pearwood.info> - 2016-03-26 22:41 +1100
Re: Suggestion: make sequence and map interfaces more similar Marco Sulla <marcosullaroma@gmail.com> - 2016-03-26 01:35 +0100
Re: Suggestion: make sequence and map interfaces more similar Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-26 10:29 +0000
csiph-web