Class-level variables - a scoping issue

Jonathan Gardner jgardner at jonathangardner.net
Wed Oct 13 08:01:30 CEST 2010


On Oct 10, 12:07 pm, John Nagle <na... at animats.com> wrote:
>      (If you want default values for an instance, you define them
> in __init__, not as class-level attributes.)
>

I beg to differ. I've seen plenty of code where defaults are set at
the class level. It makes for some rather nice code.

I'm thinking of lxml.html.cleaner right now, which has a ton of
options that would be almost impossible to manage without class
variables.



More information about the Python-list mailing list