[Python-ideas] making a module callable

Philipp A. flying-sheep at web.de
Tue Nov 19 19:09:13 CET 2013


2013/11/19 Gregory P. Smith <greg at krypto.org>

While I don't ordinarily endorse this use case it'd be nice not to require
> hacks involving sys.modules monkeying such ashttps://github.com/has207/flexmock/pull/89to make a module callable.
>
> This obviously touches on the larger ideas of what is a module vs a class
> and why are they different given that they're "just" namespaces.
>
hmm, interesting thought. there are some modules who just have one single
main use (pprint) and could profit from that.

imho it would simplify the situation. currently, everything is callable
that has a __call__ property which is itself callable:

class Foo():
    __call__(self):
        pass
    def bar():
        pass

foo = Foo()
foo()
foo.bar()
def baz():
    pass

foo.baz = baz
foo.baz()

except modules. which feels is imho like an artificial limitation.

– phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131119/a63fc7a7/attachment-0001.html>


More information about the Python-ideas mailing list