Relying on a user to correctly type a string literal is usually a bad idea as it can result in silent errors if the string contains a typo.
It is common to define uppercase variables at the module level, for instance the socket module has
socket.SOCK_STREAM
socket.SOCK_DGRAM
socket.SOCK_RAW
These are passed to functions as parameters, and could easily contain string values.
"Ideally these might be selected by: my_module.search.sort_option.FIRST_AUTHOR instead of my_module.C.FIRST_AUTHOR but that's REALLY long"
Yes that first option seems a bit long. mymodule.SORT_FIRST_AUTHOR
seems reasonable though, and using class variables could be appropriate if the constants are constrained to that class and/or if the class is likely to be imported from the module independently.
from mymodule import Searcher
s = Searcher(..., Searcher.SORT_FIRST_AUTHOR)
Prefixing the constants with a common term (like SORT) will aide editors when tab completing entries and makes the constants more descriptive.
You could also consider using a namedtuple
>>> SortOpts = namedtuple('SortOpts', ('FIRST_AUTHOR', 'LAST_AUTHOR'))
>>> SORT_OPT = SortOpts(FIRST_AUTHOR=0, LAST_AUTHOR=1)
>>> SORT_OPT.FIRST_AUTHOR
0
>>> SORT_OPT.FIRST_AUTHOR = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: can't set attribute
This has the advantage of protecting the attributes from being changed, however I don't think this will work with tab completion in most editors.