> Why does it have to be a one-liner? Is the Enter key on your keyboard
> broken?

Nah. I was simply looking for something natural and intuitive, like: m
= object(); m.a = 1;
Usually python is pretty good providing these natural and intuitive
solutions.


> You have a perfectly good solution: define a class, then instantiate it.
> But if you need a one-liner (perhaps to win a game of code golf), then
> this will work:
>
> >>> m = type('', (), {})()
> >>> m.attribute = 2

Heh. Creating it dynamically. Ace. ;)

-- Cheers, Dmitry
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to