diff options
author | ptmcg <ptmcg@austin.rr.com> | 2021-08-19 16:53:27 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2021-08-19 16:53:27 -0500 |
commit | a3846e7a973308dae9c39c584525b82cf8d73549 (patch) | |
tree | b2ac1d6eb7e2dfeefd687e52fd5f005872fc8c73 /pyparsing/unicode.py | |
parent | da022671996878a9665fc9362d5f3ab2f3aa9f11 (diff) | |
download | pyparsing-git-a3846e7a973308dae9c39c584525b82cf8d73549.tar.gz |
Add identchars and identbodychars symbols to make it easier to construct identifiers
Diffstat (limited to 'pyparsing/unicode.py')
-rw-r--r-- | pyparsing/unicode.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pyparsing/unicode.py b/pyparsing/unicode.py index 8ba459a..f41d2a0 100644 --- a/pyparsing/unicode.py +++ b/pyparsing/unicode.py @@ -71,6 +71,24 @@ class unicode_set: "all alphanumeric characters in this range" return cls.alphas + cls.nums + @_lazyclassproperty + def identchars(cls): + "all characters in this range that are valid identifier characters, plus underscore '_'" + return ( + "".join(filter(str.isidentifier, cls._get_chars_for_ranges())) + + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµº" + + "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ" + + "_" + ) + + @_lazyclassproperty + def identbodychars(cls): + """ + all characters in this range that are valid identifier characters, + plus the digits 0-9 + """ + return cls.identchars + "0123456789" + class pyparsing_unicode(unicode_set): """ |