knossos-project / knossos_utils

Python library for interacting with KNOSSOS data sets and annotation files
GNU General Public License v2.0
9 stars 9 forks source link

Mutable default arguments in chunky #9

Open mdraw opened 8 years ago

mdraw commented 8 years ago

There are multiple cases in knossos_utils/chunky.py where (mutable) lists are used as default arguments for functions.

Especially https://github.com/knossos-project/knossos_python_tools/blob/81940efc425e55b71aa37ee7b5054f08e590a38f/knossos_utils/chunky.py#L222 could cause potential bugs because of the way list_of_coords is used.

See http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments for info on why this can be problematic.

I am opening this as an issue and not just fixing it because changing the default arguments would potentially break external code using chunky.

Other occurences of lists as default arguments are in