[tuxdroid-user] Python API: store() and restore() unused
Status: Beta
Brought to you by:
ks156
From: neimad <ror...@gm...> - 2007-05-28 12:55:13
|
Hello, I was browsing the Tuxdro=C3=AFd's Python API and noticed two big functions, namely store() and restore(), whose roles are to "save" the contents of on_xxx members to s_on_xxx members and copy back s_on_xxx to on_xxx later, respectively. They don't seem to be used anywhere, though, so I'm willing to remove them entirely. However, if there's a good reason to keep them, I would rewrite them more concisely, something along the lines of: def store(self): members =3D [m for m in self.__dict__ if m[:3] =3D=3D "on_"] for m in members: self.__dict__["saved_" + m] =3D self.__dict__[m] def restore(self): members =3D [m for m in self.__dict__ if m[:3] =3D=3D "on_"] for m in members: self.__dict__[m] =3D self.__dict__["saved_" + m] And maybe even return the "saved" state instead of storing it within the object. This could be applied to clear() as well: def clear(self): for member in self.__dict__: if member[:3] =3D=3D "on_": self.__dict__[member] =3D None The problem with in doing so is that currently the objects have both variables and methods with the same name: on_status and on_status(), for example. Thus it would require to rename either of these. Comments ? Damien |