Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between argparse.Namespace and types.SimpleNamespace?

It seems they both behave exactly the same – both are like dicts but with . literal to access an item, however none of it is even a subclass of another

from argparse import Namespace
from types import SimpleNamespace

issubclass(Namespace, SimpleNamespace)  # False
issubclass(SimpleNamespace, Namespace)  # False

So, are there any differences between them two? Can argparse.Namespace be used in all cases?

like image 926
MaxCore Avatar asked Aug 05 '26 22:08

MaxCore


1 Answers

There once was a proposal to have the argparse inherit. That said, just use the types one if you are using a new enough Python; that's what it is there for.

like image 182
Aaron D. Marasco Avatar answered Aug 07 '26 11:08

Aaron D. Marasco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!