[issue17447] str.identifier shouldn't accept Python keywords

2013-03-17 Thread Raymond Hettinger
New submission from Raymond Hettinger: >>> 'def'.isidentifier() True -- components: Interpreter Core messages: 184389 nosy: rhettinger priority: normal severity: normal status: open title: str.identifier shouldn't accept Python keywords type: behavior versions: Python 3.2, Python 3.3, Py

[issue17447] str.identifier shouldn't accept Python keywords

2013-03-17 Thread Florent Xicluna
Florent Xicluna added the comment: According to the documentation, the reserved words are classified as identifiers: http://docs.python.org/3/reference/lexical_analysis.html#keywords There's an easy workaround: >>> from keyword import iskeyword >>> def is_valid_identifier(s): ... return s.

[issue17447] str.identifier shouldn't accept Python keywords

2013-03-17 Thread R. David Murray
R. David Murray added the comment: Or maybe 'is_usable_identifier' :) -- nosy: +r.david.murray ___ Python tracker ___ ___ Python-bugs-

[issue17447] str.identifier shouldn't accept Python keywords

2013-03-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Hmm. I were going to use this method for re's named group (see issue14462). There is a possibility that some third-party code uses it for checking on general Unicode-aware identifiers. The language specifification says that keywords is a subset of identifier

[issue17447] str.identifier shouldn't accept Python keywords

2013-03-17 Thread Matthew Barnett
Matthew Barnett added the comment: I already use it in the regex module for named groups. I don't think it would ever be a problem in practice because the names are invariably handled as strings. -- nosy: +mrabarnett ___ Python tracker

[issue17447] str.identifier shouldn't accept Python keywords

2013-03-23 Thread Ezio Melotti
Ezio Melotti added the comment: IMHO str.isidentifier() should not return False for Python keywords, since it's often used in contexts where Python keywords would otherwise be valid. A keyword arg to exclude keywords could be added though, assuming there are enough use cases. -- nosy

[issue17447] str.identifier shouldn't accept Python keywords

2013-03-23 Thread Roundup Robot
Roundup Robot added the comment: New changeset a7fe48dfbfe9 by Raymond Hettinger in branch '3.3': Issue 17447: Clarify that str.isidentifier doesn't check for reserved keywords. http://hg.python.org/cpython/rev/a7fe48dfbfe9 -- nosy: +python-dev ___ P

[issue17447] str.identifier shouldn't accept Python keywords

2013-03-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: I've added a clarification to the docs. Closing this report as invalid. -- resolution: -> invalid status: open -> closed ___ Python tracker ___