[Python-ideas] C# style properties

Steven Bethard steven.bethard at gmail.com
Fri Jul 13 18:01:47 CEST 2007

On 7/13/07, Neil Toronto <ntoronto at cs.byu.edu> wrote:
> On a very related topic, I find it interesting how often classes get
> abused just to provide a convenient namespace to stick things in.
> Classes are heavy things, though, with a lot of semantics and
> behind-the-scenes witchery to deal with inheritance and metaclasses and
> such-like. Why bring that baggage into it? It might be nice to be able
> to declare a one-off namespace:
>     class Foo:
>         x:
>             '''documentation'''
>             def __get__(self, instance, owner):  # self = x, instance =
> a Foo(), owner = Foo()
>                 return instance._x
>     logger:
>         '''Singleton logger object blah blah...'''
>         db = make_db_connection(...)
>         def log(self, message):
>             ...

You should look at the "make" statement PEP, which offered you
something like this:


It was withdrawn at Guido's request - partly because he didn't like
how it allowed you to indent the methods for properties.

I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy

More information about the Python-ideas mailing list