Re: [tuxdroid-user] Daemon to USB connection
Status: Beta
Brought to you by:
ks156
From: neimad <ror...@gm...> - 2007-06-09 05:54:23
|
Yet more coding style, this time in the Python API... _Continued lines_ In tuxapi_class.py, there are lots of continued lines indented (or rather, *not* intended) like the following: # create and insert a frame to match data_to_match =3D (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ SUBDATA_TP_STATUS,DATA_STATUS,DATA_VALUE,0,0,0,0,0,\ 0,0,0,0,0) data_to_match_list.append(data_to_match) Readability is very bad, and this is against the Python coding style[1] pointed to by tuxisalive[2]: =C2=AB The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. If necessary, you can add an extra pair of parentheses around an expression, but sometimes using a backslash looks better. *Make sure to indent the continued line appropriately*. =C2=BB So the code snippet above should be written like this: # create and insert a frame to match data_to_match =3D (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP, \ SUBDATA_TP_STATUS,DATA_STATUS,DATA_VALUE,0,0,0,0,0, \ 0,0,0,0,0) data_to_match_list.append(data_to_match) _Private methods and variables_ In tuxapi_class.py again, class TUXcmd has a big doc string listing all functions available to the users of the class. This is not necessary as the list can be found out using dir(). Some methods have a doc string saying "Not a user function". Their name should start with "__" (double underscore) to make them really private, which also makes such doc strings useless. Damien [1] http://www.python.org/dev/peps/pep-0008/ [2] http://www.tuxisalive.com/documentation/how-to/guidelines-for-creating-= and-packaging-an-application |