This is a packaged-up and sanely version-controlled version of the Python tools I wrote for my REPLs, divided up into a bunch of subordinate packages:
-
compilation: Abstractions for command-line macro definitions and JSON compilation databases. -
constants: Definitions of useful constants, as well as polyfills to allow certain dependencies from the Python standard library to work even when some of their moving parts are missing (i.e. Python 2, various PyPy implementations, etc). -
fs: Filesystem-related things. Submodules include:fs.filesystem: classes representing filesystem primitives likeDirectory,TemporaryDirectory,TemporaryName; a version oftempfile.NamedTemporaryFilethat works with or without the leading dot in the provided suffix (a peeve of mine); functions for common filesystem operations likewhich(…),back_ticks(…),rm_rf(…)(be careful with that one), and so forth.fs.appdirectories: pretty much a wholesale duplication of the popularappdirspackage.fs.misc: a bunch of miscellany – noteworthy standouts include a memoizedcurrent_umask(…)and a correspondingmasked_permissions(…)fs.pypath: functions for safe manipulation ofsys.path–append_paths(…)andremove_paths(…), respectively
-
repl: Tools useful in Python REPL environments – currently ANSI printing functions, for the most part. -
typespace: Contains a submoduletypespace.namespacedefiningSimpleNamespace(á la Python 3’stypes.SimpleNamespace) and a slightly more usefulNamespaceancestor class; these are used to furnish atypespace.typesnamespace that contains everything in the standard-librarytypesmodule, but with all the typenames shortened so they no longer gratuitously end in “Type”. Like e.g.types.ModuleTypeis to be found intypespace.types.Module,types.FunctionTypeistypespace.types.Function, et cetera, ad nauseum, so you can just dofrom clu.typespace import typesto lose the redundant “Type” naming suffix – which I don’t know about you but that annoys me, I mean we all know that these things are types because they are in the fuckingtypesmodule and don’t need those overly verbose extra four characters there at the end. -
dicts: Functions for wranglingdicts (and actuallyMappingandMutableMappingdescendants in general) – tools for merging and whatnot. -
exporting: Classes and enums for automatically exporting module members, naming and assigning docstrings to things that aren’t classes, functions, or modules (like e.g.lambdafunctions orNamespaceinstances), categorizing such things (using a kind of enum we call aCladethat formulates classification predicates from typelists), and APIs for all of these things. Currently a WIP – check out the first (working!) implementation in my dotfiles repo. -
keyvalue: A module that offers a super-simple key/value store for use in REPLs, based on thezictpackage – so you can stash data in one REPL instance and get it back in another separate REPL process, even those of different implementations running on disparate Python versions. -
math: the future home for math-related stuff. All there is right now is aclamp(…)function that works withnumpydtypes. -
naming: functions for determining the names of things (even module constants and other random things that generally lack things like__name__attributes) and for the importing and exporting of things by “qualified names” – for instance, you can usenaming.qualified_import(…)to import a classCurveSetfrom its packageinstakit.processors.curvesby doingqualified_import('instakit.processors.curves.CurveSet'), which that may be handier for you than composing and hard-coding animportstatement. -
predicates: tons and tons and tons of usefullambdafunctions, which I call “predicates” even though that may not be totally accurate in many cases. A lot of them take the formisXXX(thing)e.g.isiterable(thing)orisclass(thing), in each case returning a boolean value. There are also:- Convenience accessor functions:
attr(thing, 'attributeone', 'attributetwo')will returnthing.attributeoneif it exists,thing.attributetwoif the first one does not exist but the second one does, and finallyNoneif neither can be found.attr(…)and other similar accessors work with any amount of attribute names (as long as there is at least one). Shortcuts likepyattr(…)do the same thing, only they automatically expand their attributes to__dunder__names. - AND MORE!!! There really are a ton of useful things in here and one day I will list them (but not today). Have fun with it!!
- Convenience accessor functions:
-
sanitizer: functions for cleaning up unicode. Right now there is just a list-basedsanitize(…)function that tones down anything with high-value code points to the point where it can be safelyascii-ified. -
typology: This is likepredicatesbut with more predicates, most of which are based on typelists. The module is full of typelists and it uses them extensively in its predicates, viaisinstance(…),issubclass(…)and a custom version of same calledgraceful_issubclass(…)which tries very hard to work with what you give it (instead of just crapping out with aFalsereturn value). -
version: This is basically my take on thesemverpackage. I originally developed it for internal use in some of my Python projects, but it stands on its own decently enough.
Yes. Like I said, there is more to come. Do enjoy!

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
