Is my thinking Pythonic?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Aug 21 13:40:29 EDT 2008


Craig Allen:

> class Car:
>    speed = None
>    brand = None
>
>    def __init__():
>       self.speed = defaultspeed #alternately, and more commonly, get
> this speed as a initializer argument
>       self.brand = defaultbrand
>
> That solves the issue of being able to "see" all the members of an
> object by reading code... however, this all goes out the window when
> composing an instance dynamically (i.e. metaclass type stuff).

I think that's better to avoid class attributes if you don't need
them, then shade them with object attributes with the same name, etc,
it looks like a way to make things messy...

Bye,
bearophile



More information about the Python-list mailing list