Re: Emulating C++ namespaces with ChainMap and metaclass trickery

2012-10-03 Thread Mark Adam
On Wed, Oct 3, 2012 at 1:26 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > C++ namespaces are useful for encapsulating related objects within a > single file, subdividing the global namespace without using classes. > Python has modules, but they come in separate files. > > Us

Emulating C++ namespaces with ChainMap and metaclass trickery

2012-10-03 Thread Steven D'Aprano
C++ namespaces are useful for encapsulating related objects within a single file, subdividing the global namespace without using classes. Python has modules, but they come in separate files. Using Python 3.3's ChainMap type, and some metaclass trickery, I abuse the class keyword to (almost) emu