Closed jglynn closed 4 years ago
I think the namedtuple is fine, definitely a classic solution. Since the names match, you could have possibly avoided some lines with a dict update on some sort of dict-like structure. If you're curious, check out types.SimpleNamespace
, which is dict-like but with dot notation for members. Also, Python 3.7 adds dataclasses.dataclass
decorator, which I could see replacing namedtuple for a lot of applications.
And yeah, VSCode is great. It's been my full time editor for the past year when I ditched Sublime. The Python extension support is great, although coverage for JVM stuff might only be so so. I usually run both pylint and flake8 in the editor. The unit testing and remote development plugins are also 💯.
Yea, since the keys match I was thinking there would be some slick way to do it. I found a reference to the following approach which worked but apparently order matters and this could be inconsistent?
namedtuple('TupleInfo', resp.keys())(**resp)
SimpleNamepace looks neato -- it looks like I could get rid of the TupleInfo declaration entirely and just return SimpleNamespace(**resp)
huh? That seems to be working. Not sure if it had flaws.
JG
IBM Cloud toolchain: Delivery Pipeline deployed segmund to dev, including commit 5cd86ecb3e412b417178beee94586930c3de53fc
Addresses #15
Also, VSCode is kind of slick -- this is my first taste. Nice to have some linting! 🍻