On Sat, 29 Mar 2003, Ka-Ping Yee wrote:
Okay, at last to the example, then.
The following is a better formulation in the capability style --
please ignore the previous one.
The previously posted code allows names to carry authority, which
is a big no-no. This code gets rid of names altogether in the API
for file access; it's better to deal with just objects.
import os, __builtin__
class Namespace:
def __init__(self, *args, **kw):
for value in args:
self.__dict__[value.__name__] = value
for name, value in kw.items():
self.__dict__[name] = value
class ImmutableNamespace(Namespace):
def __setattr__(self, name, value):
raise TypeError('read-only namespace')
def ReadStream(file, name):
def __repr__():
return '