openlang

Bringing every name across from a module

Can I pull literally all the contents of a module into a different one?

Right now I'm forced to write


import LocalNotes;from LocalNotes import *;from LocalNotes import __html__, _mark

to import all the names I'm after, though I'd prefer to achieve that with a single statement.

The conversation continues 2

Follow the reasoning
  1. Permalink

    For a literal interpretation of “all the contents”: import LocalNotes; globals().update(LocalNotes.__dict__)

    This is likely not what you're after. Names such as __name__, __path__ get replaced too, potentially creating surprising behavior further down the line. Still, particular use cases might require that.

    Setting __all__ as described earlier is likely the appropriate approach.

Other sides of the same question

  1. Reducing docker-compose console noise

    Several of my containers produce hundreds upon hundreds of output lines when docker-compose up starts all the services in my…

    Replies 3Latest activity bash
  2. Could D produce Python extension modules rather than using C?

    Apparently D can link against C. I want to write a Python extension module using D. Is there a reason this approach could nev…

    Replies 2Latest activity d
  3. Micro plugins declared through Nix?🤔

    With python we can write this: Python.withPackages (q: with q; [ fastapi ]) Is an equivalent mechanism available for the Micr…

    Replies 3Latest activity nix