This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients ezio.melotti, rominf, steven.daprano, vstinner
Date 2018-12-22.00:37:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1545439028.86.0.98272194251.issue35549@roundup.psfhosted.org>
In-reply-to
Content
I love the idea, but dislike the proposed interface.

As a general rule of thumb, Guido dislikes "constant bool parameters", where you pass a literal True or False to a parameter to a function to change its behaviour. Obviously this is not a hard rule, there are functions in the stdlib that do this, but like Guido I think we should avoid them in general.

Instead, I think we should allow the name to include globbing symbols * ? etc. (I think full blown re syntax is overkill.) I have an implementation which I use:

lookup(name) -> single character # the current behaviour

lookup(name_with_glob_symbols) -> list of characters

For example lookup('latin * Z') returns:

['LATIN CAPITAL LETTER Z', 'LATIN SMALL LETTER Z', 'LATIN CAPITAL LETTER D WITH SMALL LETTER Z', 'LATIN LETTER SMALL CAPITAL Z', 'LATIN CAPITAL LETTER VISIGOTHIC Z', 'LATIN SMALL LETTER VISIGOTHIC Z']


A straight substring match takes at worst twelve extra characters:

lookup('*' + name + '*')

and only two if the name is a literal:

lookup('*spam*')

This is less than `partial_match=True` (18 characters) and more flexible and powerful. There's no ambiguity between the two styles of call because the globbing symbols * ? and [] are never legal in Unicode names. See section 4.8 of

http://www.unicode.org/versions/Unicode11.0.0/ch04.pdf
History
Date User Action Args
2018-12-22 00:37:09steven.dapranosetrecipients: + steven.daprano, vstinner, ezio.melotti, rominf
2018-12-22 00:37:08steven.dapranosetmessageid: <1545439028.86.0.98272194251.issue35549@roundup.psfhosted.org>
2018-12-22 00:37:08steven.dapranolinkissue35549 messages
2018-12-22 00:37:08steven.dapranocreate