Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: can't add variables to instances of built-in classes Date: Wed, 20 Jul 2016 16:19:28 +1000 Lines: 42 Message-ID: References: <4f796d95-0e87-4610-a0a8-1eff07c60ace@googlegroups.com> <578b9e62$0$22141$c3e8da3$5496439d@news.astraweb.com> <3e934f83-2076-407d-b85b-686ecdec6ff8@googlegroups.com> <2bc29306-ac90-4424-84c2-64be494c5a75@googlegroups.com> <230d1aff-b1a3-4f16-b9a6-b5d9fd07e4b4@googlegroups.com> <62dd86d4-74f7-4e97-a29c-7e45aced77d9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 5x9L0cFCrbwEhtOdikbHJgkJRnSbjtecQeKzeRteqbfQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'fixes': 0.05; 'imply': 0.07; 'wednesday,': 0.07; 'cc:addr:python-list': 0.09; 'tuple': 0.09; 'url:github': 0.09; 'wed,': 0.15; '2016': 0.16; '__slots__': 0.16; 'exactly?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'how,': 0.16; 'integer.': 0.16; 'properties,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'traceback.': 0.16; 'tuple,': 0.16; 'why,': 0.16; 'wrote:': 0.16; 'debugging': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'work,': 0.21; 'lawrence': 0.22; 'trying': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'sort': 0.25; 'wondering': 0.25; "doesn't": 0.26; 'appear': 0.26; 'sense': 0.26; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'that.': 0.30; "we're": 0.30; 'programmers': 0.30; "i'd": 0.31; 'fixed': 0.31; 'problem': 0.33; "i'll": 0.33; 'received:google.com': 0.35; 'something': 0.35; 'problem.': 0.35; 'but': 0.36; 'instead': 0.36; 'lines': 0.36; 'monday,': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'say': 0.37; 'thank': 0.38; 'why': 0.39; 'subject:-': 0.39; 'future': 0.60; 'email addr:gmail.com': 0.62; 'complete': 0.63; 'you.': 0.64; '20,': 0.66; '>>>>>': 0.66; 'jul': 0.72; 'sounds': 0.76; 'chrisa': 0.84; 'cult': 0.84; 'wasn\xe2\x80\x99t': 0.84; 'to:none': 0.91; 'subject:add': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc :content-transfer-encoding; bh=tuKRWzf0SditOjWK6iX6/UlKSdG7keW3dVyg2PsjH7M=; b=A+JQjxFHSbvG6Jz5UvTVujsRFHGoJxlzPZ6Xrd/vNq+DMCaMiuqQ4Oqblg+iX+B4we fstwE6NTOIiLR16jt6XMMBY4QRZ0OYc56b0eW4z4DwnBIScJIMpaAGKWc/ZaTpw2oJkw RPl8SucB1a93S6Egf0U5UcXx71XAfZZPF64gkyxJRRugiSQVv9Zr4+GDAd7UOCV+WJ9b 8cfONZjrpKxa0tvFe5aPADOLEI7tfmwD7mbcR39dmm6vFfqZKdymsHOb4i8sJJxwhvCI 9gtPmiMMkCbCli3s3dw53Txo2v6jNGJiCzUMGvrVOIak+qXHzTvZm8r6NY6hM5VBhMdA E2rg== 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:from:date :message-id:subject:cc:content-transfer-encoding; bh=tuKRWzf0SditOjWK6iX6/UlKSdG7keW3dVyg2PsjH7M=; b=HC7tMRipcCHytlOsT+V0rEd/b2RLf/A47UNGfYp8vBU8Kkmz9yAYkOZrRydVLcQsz9 ErHcv5WU4AVd09k74UtnAweHcb3c/VJl99/dF6ntjcVkuxYr9es29qVPbAukuJu7ij0U tpbPtkq8vQIyoyjQn2CeBnntl+C3qfzvUTTmpENn6rvl9K8ELvG2XNQWiS/2SqaBHuFi t//Yyp6SJm474Hy+WNTpMl061mgJPAlCxOLhcXFP9oQEbpdCasTtM0mONMwaGEgDscJN bhfCFHfFvp4ftrsEhcZrYN11In65IxVq8i4oNA9mEof+WBTladr1HIIZdgj4saMNvJMy 5GiQ== X-Gm-Message-State: ALyK8tJ71w4hISfMfQrwX5Bs5XwolTlVNBQi+oIOZZwOo0UxJnADfi6NArmL8AO8PYVvMHWPj58bu26/limy6w== X-Received: by 10.28.41.195 with SMTP id p186mr9704638wmp.41.1468995569893; Tue, 19 Jul 2016 23:19:29 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <4f796d95-0e87-4610-a0a8-1eff07c60ace@googlegroups.com> <578b9e62$0$22141$c3e8da3$5496439d@news.astraweb.com> <3e934f83-2076-407d-b85b-686ecdec6ff8@googlegroups.com> <2bc29306-ac90-4424-84c2-64be494c5a75@googlegroups.com> <230d1aff-b1a3-4f16-b9a6-b5d9fd07e4b4@googlegroups.com> <62dd86d4-74f7-4e97-a29c-7e45aced77d9@googlegroups.com> Xref: csiph.com comp.lang.python:111659 On Wed, Jul 20, 2016 at 9:58 AM, Lawrence D=E2=80=99Oliveiro wrote: > On Wednesday, July 20, 2016 at 9:24:57 AM UTC+12, bream...@gmail.com wrot= e: >> >> On Tuesday, July 19, 2016 at 3:54:12 AM UTC+1, Lawrence D=E2=80=99Olivei= ro wrote: >>> >>> On Tuesday, July 19, 2016 at 11:12:52 AM UTC+12, bream...@gmail.com wro= te: >>>> >>>> On Monday, July 18, 2016 at 10:48:15 PM UTC+1, Lawrence D=E2=80=99Oliv= eiro wrote: >>>>> >>>>> >>>>> When you have lots of read/write properties, I find __slots__ to be a >>>>> good idea. >>>> >>>> Please explain why, thank you. >>> >>> I was trying something like >>> >>> ctx.dashes =3D ((0.1, 0.03, 0.03, 0.03), 0) >>> >>> and wondering why it wasn=E2=80=99t working... >> >> This makes no sense to me at all. You appear to be trying to create a >> tuple, which contains a tuple and an integer. You then say it doesn't >> work, but imply that using __slots__ fixes the problem. So please expla= in >> exactly what you were trying to achieve, the exact error you got, with t= he >> complete traceback, and how using __slots__ fixed the problem. > > No traceback. The lines were simply coming out solid, instead of dashed. And __slots__ fixed the problem how, exactly? This sounds like the sort of cargo cult debugging that I'd expect of PHP programmers ("I put addslashes around everything and now it works, so in future I'll use addslashes everywhere"), but around here, we're better than that. ChrisA