ruby %w equivalent
Duncan Booth
duncan.booth at invalid.invalid
Wed Sep 27 05:03:46 EDT 2006
Nick Craig-Wood <nick at craig-wood.com> wrote:
> In python when making __slots__ or module.__all__ you end up typing
> lists of objects or methods and they turn out like this which is quite
> a lot of extra typing
>
> __slots__ = ["method1", "method2", "method3", "method4", "method5"]
>
>
For __all__ you can use a decorator to avoid retyping the function name at
all. e.g.
def public(f):
all = f.func_globals.setdefault('__all__', [])
all.append(f.__name__)
return f
@public
def foo(): pass
I don't use __slots__ much at all, and if you'd said "attribute1" etc. I'd
have understood, but I'm really curious why would you be listing any
methods in __slots__?
More information about the Python-list
mailing list