Comments (7)
If we store None
as value of dict, we face this error.
$ ipython
Python 3.9.1 (default, Feb 12 2021, 17:20:20)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: d = {"a": 10, "b": None}
In [2]: d.get("a", "red")
Out[2]: 10
In [3]: d.get("b", "red") is None
Out[3]: True
In [4]: d.get("c", "red")
Out[4]: 'red'
In [5]: d.get("b", "red").lower()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-5a428f4cd3b2> in <module>
----> 1 d.get("b", "red").lower()
from vision-tools.
The workaround is
- before
params.get("color", "red").lower()
- after
(params.get("color", "red") or "red").lower()
from vision-tools.
But unfortunately there are too many params.get(key, default_value)
in this tool. Fixing all lines by the workaround above is not realistic.
https://github.com/IBM/vision-tools/search?q=params.get%28
from vision-tools.
All params
variables are instance of docopt.ParsedOptions(dict)
. So we may be able to fix this issue by hooking this class.
from vision-tools.
I found a fundamental solution for this issue.
We can check the return value by overriding get
method of ParsedOptions
.
class ParsedOptions(dict):
...
def get(self, key, default_value=None):
if key in self:
value = super().get(key)
if value is not None:
return value
return default_value
from vision-tools.
I opened a pull request with my solution #41. Please merge it.
from vision-tools.
@bcarld Thanks!
from vision-tools.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vision-tools.