Re: object() can't have attributes

2015-12-23 Thread Zachary Ware
On Dec 23, 2015 7:00 AM, "Chris Angelico" wrote: > On Wed, Dec 23, 2015 at 11:46 PM, Neal Becker wrote: > > Sometimes I want to collect attributes on an object. Usually I would make > > an empty class for this. But it seems unnecessarily verbose to do this. So > > I thought, why not just use a

Re: object() can't have attributes

2015-12-23 Thread Chris Angelico
On Wed, Dec 23, 2015 at 11:46 PM, Neal Becker wrote: > I'm a bit surprised that an object() can't have attributes: > > In [30]: o = object() > > In [31]: o.x = 2 > --- > AttributeError

Re: object() can't have attributes

2015-12-23 Thread Chris Angelico
On Thu, Dec 24, 2015 at 2:49 AM, Irmen de Jong wrote: > Hey, nice, didn't know about SimpleNamespace. I was about to suggest > collections.namedtuple but that one is probably more than Neal asked for. > > Alternatively, you can still put attributes on a function, so this works as > well (but I >

Re: object() can't have attributes

2015-12-23 Thread Irmen de Jong
On 23-12-2015 13:58, Chris Angelico wrote: > On Wed, Dec 23, 2015 at 11:46 PM, Neal Becker wrote: >> Sometimes I want to collect attributes on an object. Usually I would make >> an empty class for this. But it seems unnecessarily verbose to do this. So >> I thought, why not just use an Object?

Re: object() can't have attributes

2015-12-23 Thread Chris Angelico
On Wed, Dec 23, 2015 at 11:46 PM, Neal Becker wrote: > Sometimes I want to collect attributes on an object. Usually I would make > an empty class for this. But it seems unnecessarily verbose to do this. So > I thought, why not just use an Object? But no, an instance of Object > apparantly can'

object() can't have attributes

2015-12-23 Thread Neal Becker
I'm a bit surprised that an object() can't have attributes: In [30]: o = object() In [31]: o.x = 2 --- AttributeErrorTraceback (most recent call last) in () > 1 o.x = 2 A