Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'resulting': 0.04; 'attribute': 0.07; 'modified': 0.07; 'apis': 0.09; 'identifier': 0.09; 'received:internal': 0.09; 'statements': 0.09; "subject:, '": 0.09; 'suggest': 0.14; 'finney': 0.16; 'identifier.': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'symbols': 0.16; 'underlying': 0.16; 'wrote:': 0.18; '(where': 0.19; 'example': 0.22; 'header:In-Reply-To:1': 0.27; 'raise': 0.29; 'subject:) ': 0.29; 'dec': 0.30; 'statement': 0.30; "i'm": 0.30; 'writes:': 0.31; 'cases': 0.33; 'fri,': 0.33; "i'd": 0.34; 'received:66': 0.35; 'case,': 0.35; 'but': 0.35; 'should': 0.36; 'received:10': 0.37; 'ben': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'subject:? ': 0.60; 'from:no real name:2**0': 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-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=mesmtp; bh=gV5at8VLul3LlMQ+8r+awapcpwc=; b=j8HT JiAR5XmElJ3ddkuIvToGmmNw8LMBCRpVgE7Pfq8jFMWFzmAUaFuVCNyHEymlwzPn s8m8zrpAqpTp0qiWrZ/PBF3X2z035XEhxNZcx5fkzIGxspXSO3JajA9yZtpuiG2F fTKxGuIzR064zYClpdMI7yCvu3SzaaHI36P55CQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:in-reply-to :references:subject:date; s=smtpout; bh=gV5at8VLul3LlMQ+8r+awapc pwc=; b=T349s741Kgjq5KWOgd6kG6VtQ33XDCYHOxTVw4bLKAPwQGn9TL4yDpPj MXZvqVXUSY54NOuBhveWMlsjJ0DsFPgvyE57c7bP5UITxZ6TDL/E1KRSEppkSnWa Is170h689ITNagfjncGfXyP1zbHdLd6DovcE/JRc4/IxFHgOgXE= X-Sasl-Enc: KKy8FRFrEDtxkHxWIjCnb3k7cMNJmPrPP7CSYVuvbmCD 1419003188 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-31f62092 In-Reply-To: <85388bomk4.fsf@benfinney.id.au> References: <7700FF95-2FE4-48D8-A6B4-A65D17CAFF91@gmail.com> <85388bomk4.fsf@benfinney.id.au> Subject: Re: Bug? Feature? setattr(foo, '3', 4) works! Date: Fri, 19 Dec 2014 10:33:08 -0500 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1419008152 news.xs4all.nl 2877 [2001:888:2000:d::a6]:33162 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82673 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. 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.)