Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82673
| From | random832@fastmail.us |
|---|---|
| References | <7700FF95-2FE4-48D8-A6B4-A65D17CAFF91@gmail.com> <85388bomk4.fsf@benfinney.id.au> |
| Subject | Re: Bug? Feature? setattr(foo, '3', 4) works! |
| Date | 2014-12-19 10:33 -0500 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17059.1419008152.18130.python-list@python.org> (permalink) |
On Fri, Dec 19, 2014, at 07:23, Ben Finney wrote: > Cem Karan <cfkaran2@gmail.com> writes: > > I'd like to suggest that getattr(), setattr(), and hasattr() all be > > modified so that syntactically invalid statements raise SyntaxErrors. > > What syntactically invalid statements? The only syntactically invalid > statements I see you presenting are ones that *already* raise > SyntaxError. > > 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? > > I'm −1 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.)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Bug? Feature? setattr(foo, '3', 4) works! random832@fastmail.us - 2014-12-19 10:33 -0500
csiph-web