namespaces module (a.k.a. bunch, struct, generic object, etc.) PEP

Nick Coghlan ncoghlan at iinet.net.au
Fri Feb 11 05:11:57 EST 2005


BJörn Lindqvist wrote:
> I like it alot! My only minor complaint is that the name is to long.
> Also I *really wish* the Namespace could do this:
> 
> r, g, b = col = Namespace(r = 4, g = 3, b = 12)
> 
> But alas, I guess that's not doable within the scope of the Namespace PEP. 

You can almost spell that already, it just won't do what you want:

   r, g, b = col = dict(r = 4, g = 3, b = 12).values()

The dict-based implementation means named tuples they ain't :)

However, the namespaces module *would* provide a natural location for a 
NamedTuple class.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list