[Python-ideas] list of reserved identifiers in program?
Daniel Fetchinson
fetchinson at googlemail.com
Fri Oct 26 11:22:30 CEST 2012
Hi folks,
Would it be a good idea to have a built-in list of strings containing
the reserved identifiers of python such as 'assert', 'import', etc?
The reason I think this would be useful is that whenever I write a
class with user defined methods I always have to exclude the reserved
keywords. So for instance myinstance.mymethod( ) is okay but
myinstance.assert( ) is not. In these cases I use the convention
myinstance._assert( ), etc. In order to test for these cases I hard
code the keywords in a list and test from there. I take the list of
keywords from http://docs.python.org/reference/lexical_analysis.html#keywords
But what if these change in the future?
So if I would have a built-in list containing all the keywords of the
given interpreter version in question my life would be that much
easier.
What do you think?
Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
More information about the Python-ideas
mailing list