[Patches] Making modules callable when they have the attribute "__call__"

Pekka Pessi Pekka.Pessi@nokia.com
Sat, 15 Apr 2000 11:27:56 +0300 (EEST)


Fred L. Drake, Jr. <fdrake@acm.org> writes:
>Pekka Pessi writes:
> > 	If we have a simple extension module, say, md5, that basically
> > 	defines one class/object type, say, md5, it is much cleaner to
> > 	define that class/object type also as __call__. Now the single
> > 	object type is sometimes called "new", sometimes something else.

>  So you're looking for:

>	import md5
>        hasher = md5('my data')
>        digest = hasher.digest()

	Actually, I'm looking something like

import socket

s = socket(socket.AF_INET6, socket.SOCK_SECKPACKET)

	where the __call__ in the socket module is something like a factory.

...
>  This seems confusing.  I don't know of other languages which make
>modules into anything other than containers/namespaces.

	What is a Python instance but a container/namespace?

					Pekka