Deprecate self

Samuel A. Falvo II kc5tja at garnet.armored.net
Wed Apr 18 16:51:58 EDT 2001


On Wed, 18 Apr 2001 22:31:28 +0200, Just van Rossum wrote:
>Modules don't have instances. Sure, modules are in many ways like classes,
>but they're not at all like instances. And only with instances the self
>discussion becomes interesting. Your analogy is moot.

Modules are every bit like instances -- a singleton instance, to be
specific.  They expose an interface, and maintain state -- just like any
object.  Internally, they're even represented by the same data structure as
an object.

What they don't do is inherit functionality from other modules, but even
that can be emulated with stuff like:

	import foo
	
	FooFunc1 = foo.FooFunc1
	FooFunc2 = foo.FooFunc2
	# ... etc...

Because they expose an interface, a module can be treated as an instance of
a class defined by the global definitions of that module (it's a recursive
definition, and this is why other dynamic OO environments have the concept
of "meta-classes" as well as classes, so as to break this recursion).

-- 
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA



More information about the Python-list mailing list