I am looking for a struct like data structure I can create multiple instances from and have some type hinting without being immutable.
So I have something like this:
class ConnectionConfig(NamedTuple):
name: str
url: str
port: int
user: str = ""
pwd: str = ""
client: Any = None
But I would like to have it mutable. I could do it like that:
class ConnectionConfig():
def __init__(self, name: str, url: str, port: int, user: str = "", pwd: str = "", client: Any = None):
self.name = name
self.url = url
self.port = port
self.user = user
self.pwd = pwd
self.client = client
But man... that is ugly :/ Are there any built-in alternatives in python? (using Python 3.6.3)
*argsand**kwargs?**kwargsand a (for) loop. And you could useeval(orexec) for this one. I'm just not sure about this because every time I use eval for assigning variables it throws an error.