Correct type for a simple "bag of attributes" namespace object

Terry Reedy tjreedy at udel.edu
Sat Aug 2 22:40:43 EDT 2014


On 8/2/2014 5:16 PM, Mark Lawrence wrote:
> On 02/08/2014 22:05, Chris Angelico wrote:
>> On Sun, Aug 3, 2014 at 6:46 AM, Mark Summerfield <list at qtrac.plus.com>
>> wrote:
>>> But perhaps what I should be asking for is for a new built-in that
>>> does what types.SimpleNamespace() does, so that without any import
>>> you can write, say,
>>>
>>> foo = namespace(a=1, b=2)
>>> # or
>>> bar = namespace()
>>> bar.a = 1
>>>
>>> where under the hood namespace has the same behavior as
>>> types.SimpleNamespace().
>>>
>>> Naturally, I understand that adding a new name is a big deal and may
>>> be too much to ask for beginners.
>>
>> This is where you might want to consider putting some imports into
>> site.py. That way, you can set up your own customized Python, without
>> waiting for changes to be approved for core (which they probably won't
>> - new builtins have a high requirement for necessity, not just "I
>> don't want to have to type import").
>>
>> ChrisA
>>
>
> I'd forgotten all about site.py so went to the 3.4.1 docs and found
> "Deprecated since version 3.4: Support for the “site-python” directory
> will be removed in 3.5.".

site-python is *nix only and differetn from site.py, which will not go 
away. I believe PYTHONSTARTUP is also cross platform.


-- 
Terry Jan Reedy





More information about the Python-list mailing list