Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93896

Re: Mapping, with sequence as key, wildcard and subsequence matching

Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'default.': 0.07; 'key.': 0.07; 'strings.': 0.07; 'attribute.': 0.09; 'length.': 0.09; 'non-default': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subclass': 0.09; 'tuple': 0.09; 'jan': 0.11; 'value.': 0.15; '*only*': 0.16; '__new__': 0.16; 'arbitrarily': 0.16; 'keys.': 0.16; 'mapping,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'sentinel': 0.16; 'subject:Mapping': 0.16; 'subject:key': 0.16; 'tuple,': 0.16; 'wrote:': 0.16; 'exists': 0.18; 'all,': 0.20; 'sets': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; '(e.g.': 0.27; 'sequence': 0.27; 'specify': 0.27; "skip:' 10": 0.28; 'itself,': 0.29; 'tail': 0.29; 'position.': 0.30; 'items.': 0.33; 'wrap': 0.33; 'could': 0.35; 'text': 0.35; 'false': 0.35; 'list:': 0.35; 'something': 0.35; 'list,': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'method': 0.37; 'say': 0.37; 'received:org': 0.37; 'data': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'special': 0.73; 'alternative.': 0.84; 'received:fios.verizon.net': 0.91; 'choice.': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Mapping, with sequence as key, wildcard and subsequence matching
Date Thu, 16 Jul 2015 01:27:36 -0400
References <85k2u0vpis.fsf@benfinney.id.au>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Gmane-NNTP-Posting-Host pool-98-114-97-173.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0
In-Reply-To <85k2u0vpis.fsf@benfinney.id.au>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Newsgroups comp.lang.python
Message-ID <mailman.556.1437024480.3674.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1437024480 news.xs4all.nl 2888 [2001:888:2000:d::a6]:35507
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 4272
X-Received-Body-CRC 3741398253
Path csiph.com!usenet.pasdenom.info!news.stben.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:93896

Show key headers only | View raw


On 7/15/2015 9:51 PM, Ben Finney wrote:
> Howdy all,
>
> What well-defined data type exists with the following properties:
>
> * Mapping, key → value.
>
> * Each key is a sequence (e.g. `tuple`) of items such as text strings.
>
> * Items in a key may be the sentinel `ANY` value, which will match any
>    value at that position.
>
> * A key may specify that it will match *only* sequences of the same
>    length.
>
> * A key may specify that it will match sequences with arbitrarily many
>    additional unspecified items.

Every key should signal which of the last two alterntives holds. One can 
be a default.  The signal can be 'in-band', in the tuple key itself, or 
'out-of-band', not in the tuple key.  An in-band signal must be a 
special value, like 'ANY', that is not otherwise used in keys.  ... 
might be a good choice.  For out-of-band, you could try a tuple subclass 
with a __new__ method that sets an attribute.  Or wrap a tuple, say with 
a list, to signal the non-default alternative.  Something like

     tail = False
     if type(key) is list:
         tail = True
         key = key.pop()

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Mapping, with sequence as key, wildcard and subsequence matching Terry Reedy <tjreedy@udel.edu> - 2015-07-16 01:27 -0400

csiph-web