This article is for Python 2.7 only. May be incorrect for Python 3.x.
1. super() should not be referenced.
Bad practice:
|
|
This will throw TypeError: can't pickle thread.lock objects will be raised if you try to dump an object of class bar.
Good practice:
|
|
2. Caused by Logging.
If you are using build-in logging module together with th build-in pickle module, this exeption may casued by the conflict between them.
Bad practice:
|
|
logger object cannot be dumped by Pickle in Python2.7. The logging module implements a thread-safe logging mechanism with thread.lock in it. To resolve this issue, you may use the getLogger() method instead of an explict reference to a logger object.
Good practice:
|
|
3. If you are using sklearn.
Sometimes your may need to override an existing sklearn.estimator. Remember that if you are adding any new parameter to your wrapper class, please set them as object variables in __init__().
See the following example of overriding sklearn.preprocessing.Imputer.
Bad practice:
|
|
Good practice:
|
|

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.