Re: A useful, but painful, one-liner to edit money amounts

2010-08-07 Thread Rebel Lion
On Aug 5, 12:33 pm, John Nagle wrote: > There's got to be a better way to do this: > > def editmoney(n) : >      return((",".join(reduce(lambda lst, item : (lst + [item]) if >          item else lst, >          re.split(r'(\d\d\d)',str(n)[::-1]),[])))[::-1]) > >  >>> editmoney(0) > '0' >  >>> edit

Re: Inheritable Slots Metaclass

2010-05-26 Thread Rebel Lion
> I'd be ok with a metatype in the standard library that makes slots > more transparent, but since slots are intended as an optimization, it > doesn't really need (and might be detrimental to have) transparency > for ordinary objects. > But why there is __slots__ if it's not indeed needed. we sho

Inheritable Slots Metaclass

2010-05-26 Thread Rebel Lion
I made a metaclass to inherit __slots__ automatically. I think this feature should be included in builtin object's metaclass. You can now write: class Foo(object): __metaclass__ = SlotMetaclass @slot def foo(): pass class Bar(Foo): @slot