Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Asymmetry in globals __getitem__/__setitem__ Date: Fri, 13 Jun 2014 09:07:45 +0300 Organization: A noiseless patient Spider Lines: 21 Message-ID: <878up1wde6.fsf@elektro.pacujo.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="32423"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18A4SWQO9S3jw+E16b2TUtX" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:jmf8WEq+vsm9PtDdXU1cQntO+f8= sha1:F2SrKB5QCHRCqoDb3ikxFTn2sXs= Xref: csiph.com comp.lang.python:73255 Gregory Ewing : > I didn't think that using a custom mapping object for globals was > officially supported. Has that changed? The documentation is a bit vague about it: If only globals is provided, it must be a dictionary, which will be used for both the global and the local variables. If globals and locals are given, they are used for the global and local variables, respectively. If provided, locals can be any mapping object. Now, if you define: class Namespace(dict): ... A Namespace *is* a dict[ionary] in the classic OOP sense. Marko