Git Product home page Git Product logo

clu's People

Contributors

fish2000 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

clu's Issues

CLU doesn’t work on Windows

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.

Consider wrapping fallback callables installed in ProxyModule subtypes

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:

  1. 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.

  2. 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.

  3. 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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.