Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up Date: Mon, 1 Feb 2016 00:27:48 +1100 Lines: 19 Message-ID: References: <56add21a$0$1593$c3e8da3$5496439d@news.astraweb.com> <56adde86$0$1601$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de w5/DwUgDI6uqoka/KxpIYADBGVFaCtem5NbUidCGQdww== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:209.85.223': 0.03; 'json': 0.05; 'semantic': 0.07; 'cc:addr:python-list': 0.09; 'oh,': 0.09; 'python': 0.10; 'jan': 0.11; 'subject: \n ': 0.15; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'nested': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '31,': 0.22; 'parsing': 0.22; 'header :In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'structure,': 0.29; 'certain': 0.31; 'generally': 0.32; 'subject:all': 0.32; "d'aprano": 0.33; 'loading': 0.33; 'steven': 0.33; 'structure': 0.34; 'file': 0.34; 'lists': 0.34; 'received:google.com': 0.35; "isn't": 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'instead': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'someone': 0.38; 'data': 0.39; 'easily': 0.39; 'software': 0.40; 'design,': 0.61; 'numerous': 0.66; 'levels': 0.70; 'blob': 0.84; 'chrisa': 0.84; "else's": 0.84; 'to:none': 0.91; 'yours.': 0.93; 'imagine': 0.96 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:cc :content-type; bh=cKiR9KVntcKRgWgNb9MoNxiRFk4H7Ijhz/t0NtPbq5k=; b=p0rdQF551fHCLH0DTBPmaaRr6UnQWVgpFio3TW2tWTOrSfsC8Lrf1Ixs0HSgb5i9CT d/2Dqpoo4wjoJvmUVJkYQ0SgWd6O9clfBTSRVqfEqX4GuWmhQMlwrSkCaScy3vJ+bJqf PNI+/wHo73hgaa6S7LO49ei39Auj+cGxL7gHQaSiqjE/1nw0IFN1sSQsMSZvRoCvhEI1 35CFHv4ErIneFxn2r6Tt+cSWvR33jegowU15PR7WIIihIMdQC8UycWRCPTYZyOhBXwYg jlyvw8Fk6BS1bxRTC56bk/PuKpzPydDr4e0hYiymSIxc6Rytxk41/7YCM08j+fnriPyS pVKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=cKiR9KVntcKRgWgNb9MoNxiRFk4H7Ijhz/t0NtPbq5k=; b=OhAJltMfFEjrwrcZ1/+pvo6cvVJo3JVHEvJYddj6lGtlPgS8b9EkjeLvrL/4G/B1RA 8G5cQG6KckjcfJ8zzZ/wppUERYboW0PBsxVI6fP1AaSN0fAzkb+goOISIUxe8d2Oag3t qL8ZpBiQEnQClL3UF4zFPOsQ8U/Zq2c8uDKwVUzjKYsNNmsBv/ADJr3RIa39rdDpUgbu Y+j8g/E9OXvSQTP8oFUWZLcI+NYv2zyrF7D8EuJhBdY1tGf3JuiHaKy7ddHy6Hir9V2N QESm9X/eN7PzzD/FVJ/HOgAHrioXu7+3cQF87UIjNjHmy5QrVNHtkgrLGAHadQ5OnCaF hV6Q== X-Gm-Message-State: AG10YOSUSdO0uD4NCHbCe30bw5j4REjFl6bnI7xs93LvX0Rr63DclUK6pHDlO9Ozn10/msNLUXn6h/2ihzEOrw== X-Received: by 10.107.40.76 with SMTP id o73mr17138980ioo.157.1454246868096; Sun, 31 Jan 2016 05:27:48 -0800 (PST) In-Reply-To: <56adde86$0$1601$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102357 On Sun, Jan 31, 2016 at 9:14 PM, Steven D'Aprano wrote: >> Imagine taking a large and complex JSON blob >> and loading it into a Python structure with nested lists and dicts - >> it wouldn't violate software design principles to call up >> info["records"][3]["name"], even though that's three indirections in a >> row. Parsing HTML is even worse, as there's generally going to be >> numerous levels of structure that have no semantic meaning (they're >> there for layout) - so instead of three levels, you might easily have >> a dozen. > > This might not be a Law of Demeter violation, but it's certain a violation > of "Flat Is Better Than Nested". Oh, absolutely! But "Flat is better than nested" is a principle of design, and when you're parsing someone else's data structure, you follow their design, not yours. This isn't the best of designs, but it's what works with the file he has. ChrisA