Rather than create your own object, you can use argparse.Namespace
:
from argparse import Namespace
ns = Namespace(**mydict)
To do the inverse:
mydict = vars(ns)
More Related Contents:
- UnboundLocalError on local variable when reassigned after first use
- What’s the scope of a variable initialized in an if statement?
- Python nested functions variable scoping [duplicate]
- How to create module-wide variables in Python? [duplicate]
- Python – Why is this class variable not defined in the method?
- How references to variables are resolved in Python [duplicate]
- The letter ‘n’ is invalid syntax in Python? [closed]
- How to get the value of a variable given its name in a string? [duplicate]
- Scoping in Python ‘for’ loops
- Instance variables vs. class variables in Python
- Scope of python variable in for loop
- Explaining the ‘self’ variable to a beginner [duplicate]
- How to access outer class from an inner class?
- How can I change a global variable from within a function?
- Calling variable defined inside one function from another function
- Why does assigning to my global variables not work in Python?
- Getting an instance name inside class __init__() [duplicate]
- Python scope: “UnboundLocalError: local variable ‘c’ referenced before assignment” [duplicate]
- How do I pass variables across functions?
- Assigning values to variables in a list using a loop
- How can a function access its own attributes?
- Python: Using vars() to assign a string to a variable
- Does filehandle get closed automatically in Python after it goes out of scope?
- Returning Variables in Functions Python Not Working Right
- Nested list comprehension scope
- How to force/ensure class attributes are a specific type?
- How to assign each element of a list to a separate variable? [duplicate]
- How do the scoping rules work with classes?
- How to retain leading zeros of int variables?
- using variable in import command