2012-12-21 22:09:41 |
Zhongyue Luo |
description |
The _filters function checks twice whether convert_list_to exists in lines 86 and 91.
This is hard to understand and not readable.
We should assign a callable object to convert_list_to and execute it in one place to help understand the flow.
There can be three cases,
1) convert_list_to exists: then just use it directly
2) convert_to exists: the use "lambda values_: [convert_to(x) for x in values_]" as convert_list_to
3) convert_to does not exist: then use "lambda values_: None" as convert_list_to
Then, update res only if the return value of convert_list_to(values) is not None. |
The _filters function checks twice whether convert_list_to exists in lines 86 and 91.
This is hard to understand and not intuitive.
We should assign a callable object to convert_list_to and execute it in one place to help understand the flow.
There can be three cases,
1) convert_list_to exists: then just use it directly
2) convert_to exists: the use "lambda values_: [convert_to(x) for x in values_]" as convert_list_to
3) convert_to does not exist: then use "lambda values_: None" as convert_list_to
Then, update res with the return value of convert_list_to(values) if not None or else the original value. |
|
2013-01-04 01:28:19 |
Zhongyue Luo |
description |
The _filters function checks twice whether convert_list_to exists in lines 86 and 91.
This is hard to understand and not intuitive.
We should assign a callable object to convert_list_to and execute it in one place to help understand the flow.
There can be three cases,
1) convert_list_to exists: then just use it directly
2) convert_to exists: the use "lambda values_: [convert_to(x) for x in values_]" as convert_list_to
3) convert_to does not exist: then use "lambda values_: None" as convert_list_to
Then, update res with the return value of convert_list_to(values) if not None or else the original value. |
The _filters function checks twice whether convert_list_to exists in lines 86 and 91.
This is hard to understand and not intuitive.
We should assign a callable object to convert_list_to and execute it in one place to help understand the flow.
There can be three cases,
1) convert_list_to exists: then just use it directly
2) convert_to exists: the use "lambda values_: [convert_to(x) for x in values_]" as convert_list_to
3) convert_to does not exist: then use "lambda values_: None" as convert_list_to
Then, update res with the return value of convert_list_to(values) if not None or else update with the original value. |
|