A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/296203.html below:

__call__ in module?

__call__ in module? __call__ in module?Qopit russandheather at gmail.com
Tue Sep 27 18:40:22 EDT 2005
Nope - you can't even force it by binding a __call__ method to the
module.

For future reference, you can check to see what things *are* callable
with the built-in function 'callable'.

eg (with sys instead of MyApp):

>>> import sys
>>> callable(sys)
False

Also - a thing you can do to sort of do what you want (?) is wrap the
code to be executed by the module in a main() function.  eg:

  #-- Start of MyApp.py --
  def main(foo):
    print "My cat loves", foo

  if __name__ == "__main__":
    import sys
    main(" ".join(sys.argv[1:]))
  #-- EOF --

The main function then lets you either run your module from the command
line (MyApp.py Meow Mix) or have another module use it with:

  import MyApp
  MyApp.main("Meow Mix")


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4