Ah Python, you have spoiled me for all other languages

Ian Kelly ian.g.kelly at gmail.com
Fri May 22 17:20:02 EDT 2015


On Fri, May 22, 2015 at 2:55 PM, Tim Chase
<python.list at tim.thechases.com> wrote:
> I've wondered this on multiple occasions, as I've wanted to just make
> an attribute bag and have to do something like
>
>   class AttrBag(object): pass
>   ab = AttrBag()
>   ab.x = 42
>   ab.y = "some other value"
>
> because just doing
>
>   ab = object()
>
> raises the AttributeError Marko highlights. :-/

This is what types.SimpleNamespace is for.



More information about the Python-list mailing list