fish2000 / clu Goto Github PK
View Code? Open in Web Editor NEWCommon Lightweight Utilities, or Command-Line Utilities (your pick)
License: Other
Common Lightweight Utilities, or Command-Line Utilities (your pick)
License: Other
I don’t use Windows, I don’t currently have Windows, I don’t know Windows – I don’t know Python on Windows, I don’t know how anything POSIX-y works on Windows, I kind of detest how file paths work on Windows.
That said, I don’t dislike Windows, and I’d love to support Windows. This’d be, I am assuming, a big deal. Any assistance’d be welcome.
Right now, if you set up your own ProxyModule, the initialization code makes use of three different types of fallback callables – functions that get called with an attribute name that can’t be normally found in any of the ProxyModule target modules or mappings:
Module-level __getattr__(…)
functions – like e.g. this one – which these are a relatively new sort of thing. They take the name of a key or attribute or whatever, and either return something (literally anything, I believe) or raise an AttributeError
about it.
Dictionary-subtype __missing__(…)
methods – as you can see from the link above to the ChainModuleMap.__missing__(…)
source, this method gets called when __getitem__(…)
can’t cut the mustard. It’s a method, so there’s a self
in there – otherwise it’s like the module __getattr__(…)
function: take a key, return a thing, or raise. The exception to be raised in this case is a KeyError
, but as long as that’s been considered, one can pull the bound method off a dictionary instance and treat it more or less like the module function.
Arbitrary, user-furnished callables – my point of concern in this issue. Consider the callable I threw together for the inline test that covers this feature:
def fallback_function(key):
if key.isupper():
return f"NO DOGG: {key}"
raise KeyError(key)
… There’s a criterion the function uses to decide if it should return or raise, and what it raises is a specific exception type. This type of thing is fine if you’re actually implementing one of the special function hooks from 1) or 2). But for these one-off callable fallback things, should we be aiming for something more, I dunno, casual?
Like in the clu.dispatch
module, most functions are wrapped and re-wrapped to ensure that safe, sane, and non-idiotic return values happen. Granted, all that stuff concerns itself with orderly-shutdown semantics and POSIX signals and other nuances necessitated by the meshing of several real-world boundary APIs. Whatever, we can do the same thing here, doggie.
The question before you is: should we wrap the non-dunder, non-special-to-Python fallback callables, like to eschew exception mechanics in favor of (say) some sort of sentinel? Or some sleight-of-yield
abstractions that allow for statefulness, maybe? Do people want that?
q.v. this SO question sub.:
… I am not at all well-versed in coverage.py
or any of the constellation of tools with which it interoperates. Suggestions welcome, indeed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.