variables of the class are not available as default values?

Aahz aahz at pythoncraft.com
Sat Aug 29 03:25:57 CEST 2009


In article <mailman.547.1251409496.2854.python-list at python.org>,
Chris Rebert  <clp2 at rebertia.com> wrote:
>
>class foo:
>    def __init__(self, maxvalue):
>        self.maxvalue =3D maxvalue
>        self.value =3D 0
>
>    def put(self, value=3DNone):
>        self.value =3D self.value if value is None else value

Stylistic nit:

I'd make that

        self.value = value if value is not None else self.value

The reason is that the "primary" value should go first.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"I support family values -- Addams family values" --www.nancybuttons.com



More information about the Python-list mailing list