News for hackers. Stuff that matters.
Re:Show HN: Wat – Deep inspection of Python objects by notpushkin on Friday July 26, 2024 @07:33AM (#41077751)
It is kinda black magic, and I think it's not something people would expect. You can import other things just fine though:

    import sys

    def wat(): print("wat")
    def bar(): print("bar")

    wat.wat = wat
    wat.bar = bar

    sys.modules[__name__] = wat
...

    >>> import wat
    >>> wat()
    wat
    >>> from wat import bar
    >>> bar()
    bar
Edit: I think a better way would be to instead add __call__ to the current module somehow though.

There are no comments on this comment yet.