Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'resulting': 0.04; 'interpreter': 0.05; 'attribute': 0.07; 'debug': 0.07; 'modified': 0.07; 'apis': 0.09; 'identifier': 0.09; 'statements': 0.09; "subject:, '": 0.09; 'suggest': 0.14; 'behavior,': 0.16; 'finney': 0.16; 'identifier.': 0.16; 'suggestion.': 0.16; 'symbols': 0.16; 'underlying': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'trying': 0.19; '(where': 0.19; '>>>': 0.22; 'example': 0.22; 'to:name :python-list@python.org': 0.22; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'raise': 0.29; 'subject:) ': 0.29; 'dec': 0.30; 'said,': 0.30; 'statement': 0.30; "i'm": 0.30; 'changed.': 0.31; 'ctypes': 0.31; "user's": 0.31; 'writes:': 0.31; 'anyone': 0.31; 'cases': 0.33; 'fri,': 0.33; "i'd": 0.34; "can't": 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'raising': 0.36; "didn't": 0.36; 'should': 0.36; 'error.': 0.37; 'message-id:@gmail.com': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'dave': 0.60; 'subject:? ': 0.60; "you're": 0.61; 'header:Message-Id:1': 0.63; 'name': 0.63; 'such': 0.63; 'invalid': 0.68; '2014,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=wjJMVQhOal3HEhCu9g1SgtdvK6Dm8zm+5kqnYCm/uiY=; b=eca+ujgXtFw/LH491ii94y6w5+840fuNzA1dlFr5RiAPqAsIxXTtHvSwZe9wXn1Gdp CFT1S66SUS4kWgQIarDmsWuhGbNDS+244qxhQEpHUZZbv3rkdOoz8I1L2mu8jcBdctqd odIKAXq5mmqZJX56Jmfp8b9Mn8QwtA/5df88c82Ru5eRckXRKXUxgHeP0TV0B8WOqTuQ yCZeRu6ywVKRSKlxSKzfasLPKLc6qr0YNu7zWnp4XfxWYv/iPdrTMcHl9Pp08JbZe5RA lRBzz8mLScqZdfSh9D/fsOXSmn/jiLSrEunZGwzTxPL39lFVDZ+kxIoM6gwwAbP8qts5 cg9A== X-Received: by 10.170.63.212 with SMTP id f203mr11770901ykf.63.1419082220293; Sat, 20 Dec 2014 05:30:20 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Bug? Feature? setattr(foo, '3', 4) works! From: Cem Karan In-Reply-To: <1419003188.436339.204884949.792846D0@webmail.messagingengine.com> Date: Sat, 20 Dec 2014 08:30:27 -0500 Content-Transfer-Encoding: quoted-printable References: <7700FF95-2FE4-48D8-A6B4-A65D17CAFF91@gmail.com> <85388bomk4.fsf@benfinney.id.au> <1419003188.436339.204884949.792846D0@webmail.messagingengine.com> To: "python-list@python.org" X-Mailer: Apple Mail (2.1510) 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1419082228 news.xs4all.nl 2868 [2001:888:2000:d::a6]:51015 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82696 On Dec 19, 2014, at 10:33 AM, random832@fastmail.us wrote: > On Fri, Dec 19, 2014, at 07:23, Ben Finney wrote: >> Cem Karan writes: >>> I'd like to suggest that getattr(), setattr(), and hasattr() all be >>> modified so that syntactically invalid statements raise = SyntaxErrors. >>=20 >> What syntactically invalid statements? The only syntactically invalid >> statements I see you presenting are ones that *already* raise >> SyntaxError. >>=20 >> I think you mean that setting an attribute on an object should be a >> SyntaxError if the resulting attribute's name is not a valid = identifier. >> But why should a valid statement produce SyntaxError? >>=20 >> I'm =E2=88=921 on such a change. >=20 > And some APIs - ctypes, for example - actually require using getattr > with an invalid identifier in some cases (where attribute access is = used > for an underlying concept with names that are usually, but not always, > valid identifiers: in ctypes' case, looking up symbols from DLLs.) This is the one part I didn't know of; if ctypes requires this behavior, = then it can't be changed. Dave Angel, the reason I wanted to raise a SyntaxError is because from a = user's point of view they look like the same type of error. That said, = you're right that for anyone trying to debug the interpreter itself = raising SyntaxError would make things confusing.=20 Regardless, because ctypes requires it, it can't be changed. I'm = dropping the suggestion. Thanks, Cem Karan=