Sometimes, I miss "proper macros". A lot. I'm trying to get an old stinker of a project done and dusted (it's essentially a re-write, in another language, of an older project; but back-ending onto a database, with only a client/server approach as opposed to the "same, almost, API; either local library modifying back-end straight or clients/server via network"). OK, I am moving teh project from C to Python (notice that "database backend"? that'd be why).
But as part of the new rewrite, I want to have some sensible exception/error handling and to my mind that means handling different types of errors differently (it's basically a workflow system and map errors, user-related errors and item-related errors are all fundamentally different). But, alas, this means I end up writing several lines of almost-duplicate code (class declaration differing in only class name; __init__ declaration identical; __init__ body, differing in one string).
It feels horribly inefficient and should, probably, have been compressable with either a code generator (free-standing from the rest of the code, requires a separate phase to run) or by a sufficiently flexible macro system.
But! I shall persevere! It is good for the soul (hah, I'm not even fooling myself) to experience pain. I guess I could the pre-existing code away and rewrite everything from scratch (OK, not the db schema, I'm sufficiently happy with that). But that'd be, like, a pain too.