The Python Oracle

What is the right way to treat Python argparse.Namespace() as a dictionary?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Realization

--

Chapters
00:00 Question
01:17 Accepted answer (Score 573)
01:55 Answer 2 (Score 110)
02:23 Answer 3 (Score 2)
02:52 Answer 4 (Score 0)
03:27 Thank you

--

Full question
https://stackoverflow.com/questions/1687...

Question links:
[collections.Mapping]: http://docs.python.org/2/library/collect...

Accepted answer links:
[vars()]: http://docs.python.org/3/library/functio...

Answer 2 links:
[Straight from the horse's mouth]: https://docs.python.org/3/library/argpar...
[vars()]: https://docs.python.org/3/library/functi...
[The Namespace object]: https://docs.python.org/3/library/argpar...

Answer 3 links:
[hasattr]: https://docs.python.org/3/library/functi...
[similar answer to another question]: https://stackoverflow.com/a/610893/26510
[getattr method]: https://docs.python.org/3/library/functi...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #dictionary #ducktyping

#avk47