Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'subject:Python': 0.06; 'matches': 0.07; 'only,': 0.07; 'table.': 0.07; 'function,': 0.09; 'implements': 0.09; 'lookup': 0.09; 'mind,': 0.09; 'variant': 0.09; 'wrong,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '10:17': 0.16; ':-(': 0.16; 'cc:name:python list': 0.16; 'dice': 0.16; 'dict': 0.16; 'keyed': 0.16; 'keyword,': 0.16; 'simplest': 0.16; 'subject:user': 0.16; 'tables,': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'have:': 0.19; 'solution.': 0.20; '>>>': 0.22; 'handles': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'creating': 0.23; 'error': 0.23; 'entries': 0.24; 'string,': 0.24; 'fine': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'tables': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'clever': 0.31; "d'aprano": 0.31; 'keys': 0.31; 'second,': 0.31; 'steven': 0.31; 'themselves': 0.32; 'quite': 0.32; 'table': 0.34; "i'd": 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'data,': 0.36; 'subject:New': 0.37; 'turn': 0.37; 'nov': 0.38; 'pm,': 0.38; 'rather': 0.38; 'skip:8 10': 0.39; 'how': 0.40; 'subject: / ': 0.60; 'worry': 0.60; 'course': 0.61; 'first': 0.61; 'more': 0.64; 'to:addr:gmail.com': 0.65; '100': 0.79; 'imagine': 0.93; 'washington': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KbkWilNZHnMP+60rqFeGaHs5SSL/S/waXMxfFQujGO0=; b=wQxeu9GIDnTELirjJ3QoOPRhToIdPi7yOOi7hOKmPsOKjC7KVTp5ATT/XtyzgtfSyz 8ArIDRXCRJxB7JW4ie9dty7V+jHK5UwGmDz26/7IYsIL0uRQ/qvQ7pNLnb6GtoSVP03n VK0r40iM/etWdkaT/mvalW+7rmJWuPoxp0VlXZdpsHoKkmUJYJzgggdzwouAM83SdWB7 oaH6ITRAuysmpzd5eKDTfF5Oc+T7IsT8N2+kC+kXDO3KAgFfcdVqnV31dEHXrsdlHu2S YT0ibkupefRz94GyNWuHj3ByZVLtqEHvosmAX+s3ZiWnHBVetIzbC0HmI2ArvW/RC7fS YSVA== MIME-Version: 1.0 X-Received: by 10.180.189.80 with SMTP id gg16mr13806049wic.32.1384208959079; Mon, 11 Nov 2013 14:29:19 -0800 (PST) In-Reply-To: References: <-JadnUirYuhUruPPnZ2dnUVZ8rSdnZ2d@bt.com> <1c4c0901-f80a-42f3-9df5-7e7431353079@googlegroups.com> <5280bcbc$0$29976$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 11 Nov 2013 14:29:18 -0800 Subject: Re: New user's initial thoughts / criticisms of Python From: Mark Janssen To: Chris Angelico Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384208960 news.xs4all.nl 16001 [2001:888:2000:d::a6]:41065 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59106 On Mon, Nov 11, 2013 at 3:32 AM, Chris Angelico wrote: > On Mon, Nov 11, 2013 at 10:17 PM, Steven D'Aprano > wrote: >> On Mon, 11 Nov 2013 21:39:27 +1100, Chris Angelico wrote: >>> denormalizes it into a lookup table by creating 70 entries quoting the >>> first string, 15 quoting the second, 5, and 10, respectively. >> >> Ewww :-( >> >> Imagine having to print out the dict looking for an error in the lookup >> table. Or imagine the case where you have: >> >> 0...20000: do this >> 20001...890001: do that >> 890001...890003: do something else >> >> Don't get me wrong, it's a clever and reasonable solution for your >> specific use-case. But I'd much rather have a lookup table variant that >> matches on intervals. > > Of course it's "Ewww" in isolation :) But just imagine there are piles > and piles of these tables, themselves keyed by keyword, and I want to > be able to let untrusted people create tables (which means they > basically have to be data, not code). Also, bear in mind, all the > tables are based around dice that can be physically rolled, so none > has more than 100 entries after denormalization. Quite a lot of the > tables actually have unique entries per value (eg it's a d10 roll, > with ten unique outputs), so it's simplest to just turn all the tables > into that format; that way, the main code needs worry about one type > only, and the preprocessor handles the denormalization. Hmm, I automatically think of creating a hash function, but then that's how Python implements keys in dicts, so a dict is fine solution. -- MarkJ Tacoma, Washington