Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'else:': 0.03; 'encoding': 0.05; 'subject:Python': 0.06; 'list?': 0.07; 'lawrence': 0.09; 'sys,': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '7:45': 0.16; 'object),': 0.16; 'param': 0.16; 'worst': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'thu,': 0.19; 'feb': 0.22; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'bytes': 0.24; 'case.': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'character': 0.29; 'ease': 0.30; 'code': 0.31; 'easier': 0.31; 'anyone': 0.31; 'maintaining': 0.32; '-----': 0.33; "can't": 0.35; 'agree': 0.35; 'add': 0.35; 'useful': 0.36; 'should': 0.36; 'sometimes': 0.38; 'subject:': 0.39; "couldn't": 0.39; 'extremely': 0.39; 'remove': 0.60; 'read': 0.60; 'received:67.195': 0.60; 'received:98.137': 0.60; 're:': 0.63; 'header:Reply-To:1': 0.67; '26,': 0.68; 'email addr:python.org"': 0.68; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; '2015': 0.84; 'complaint': 0.84; 'confusing': 0.84; 'defensive': 0.84; 'hardly': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'shadow': 0.84; 'subject:Practices': 0.84; 'technique.': 0.84; 'do:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1424984941; bh=NQ9Fn6XO6ZgfPG8jA+7XkTZhOVHdxFH4go0YSAhLo2M=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=nd/WnD3E2Jiru1t/SBfJvFkERz5DSqaFEmWHJnbpxAOhjEhxKygybrt/q8iBSUWNHiLXRJXj8lho9Z/qxl15JgD53fs7P+T3FR8G21Oa9RwWMJgoRjVsETKpcIu7fqOv3egF6zCheiztGbaxNKfasXKgHw1A+L9lG90VMUKmHCTDc8bmUElR085Ulu5otrsZJacuGRkeS1Xq4NigCXVLKhXINrY5X8xqF7d5fX4lKPJbcF/yeh+UfBOz9xK60yZvZPJ9+JWJti2lwyCefEftICFySwRh8J7J21d73TmT18iG0JjasUeZwUJP4nRxpgE2EojUkMKbwQ3GrePkibKMvA== X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 585025.57311.bm@omp1026.mail.gq1.yahoo.com X-YMail-OSG: HrdVKsoVM1lRvMYWHXhanFgy6EF.z0tKxeGFuu3XKF2yuO21eyf_PxInZS3v5OU nGLzdVWP7RWw7FrcQ0MetzTXB394Ca1.9BDlkcCS3Yhl5L.2PrcXYJ1OwGrEC5FAO8ZsjtGxQBcU .4Rny4Mm7l_v_AsjLNBJenQgxAe2me70EyiBzHmca7C8p_9F1nsjv5u8mS2AY9ogyaZK_CU3RzWy sawO3cppoZ14mwFXEKqU.L0KMmL6CZO8T3tjk.jknSQ6GGShBNFHWd9.i5IOvXfIDRRY_AzHV2M3 UC11PeqSXk.p1S3NZLlkN1.dQciNh.FR4RPeFKrjZwBNWwGkqRhuDv4hT1IyvHlbTyF_7FQV1nPO O_VUUH2dMryPhcKwzvZ5w2BU31bjd2PZTa_iUg3SZhr4.s19DmUQdiVvlcFS5HVqNEvHe6KZIrWC MTOptdLL4WfwUno5Ds6QucasQFBlocTw.drKG.9V5g1o6SoJZcxkw1pKzqRWtPCInn8cwA.gcKSL jC38sENMLVZfCqPtR_wNHQLFIjrtGjKpsH_uwRhA2203TSa2dNi7REmkZQgNmkWfbsx.ShUZ0oQJ wuzmKJCHTFBrAdo7VSWPm_Y7dN6AVySrcjPy1g7iJhg-- Date: Thu, 26 Feb 2015 21:05:58 +0000 (UTC) From: Albert-Jan Roskam To: Simon Ward In-Reply-To: <2f8fd253-6abb-455b-bf1f-e7e3af87239d@email.android.com> References: <2f8fd253-6abb-455b-bf1f-e7e3af87239d@email.android.com> Subject: Re: Python Worst Practices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Albert-Jan Roskam 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424985071 news.xs4all.nl 2945 [2001:888:2000:d::a6]:38630 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86546 ----- Original Message ----- > From: Simon Ward > To: > Cc: "python-list@python.org" > Sent: Thursday, February 26, 2015 8:36 PM > Subject: Re: Python Worst Practices > > > > On 25 February 2015 21:24:37 GMT+00:00, Chris Angelico > wrote: >> On Thu, Feb 26, 2015 at 7:45 AM, Mark Lawrence >> wrote: >>> http://www.slideshare.net/pydanny/python-worst-practices >>> >>> Any that should be added to this list? Any that be removed as not >> that bad? >> >> Remove the complaint about id. It's an extremely useful variable name, >> and you hardly ever need the function. > > You can add one character and avoid the conflict with "id_" and not > require anyone else maintaining the code to think about it. As rare as the > conflict is, I think the ease of avoiding it makes the extra character a > practical defensive technique. I agree it is not a worst case. > I sometimes do: import sys, functools if sys.version_info.major > 2: bytez = functools.partial(bytes, encoding="utf-8") else: bytez = bytes # nog encoding param in python 2. I bitez you when you shadow 'bytes' (I can't remember when I couldn't use the functools.partial object), though it often works. Much easier to use 'bytez' or 'bytes_'. It is annoying to 'unshadow' your code and confusing for others who might read your code. Albert-Jan