So a lot of the time my utils
end up with a structure that mirrors the core library. I might end up writing a multiline version of str.center
, an itertools
-y function that returns the first or last element of an iterator that matches a predicate, a datetime
function that returns the end of the current day, maybe a custom json
encoder to extend json.dumps/loads
.
I could reexport these from modules that have the same name as the core modules: myproject.utils.string
, myproject.utils.itertools
, myproject.utils.datetime
, and, if I reexport *
from the original module, I can replace import json
with import myproject.utils.json
. (This is what, for example, Flask does with its json
module.) But that feels like a recipe for confusion.
Alternatively, I could give them a name based on the original modules, maybe xstring
, xitertools
, (in retrospect, this seems gross if not adult-rated).
Are there better options? What would best practices be?