I need to check if the objects read from the file (and evaled) using ConfigParser, are mappings.
Not quite sure of the terminology, but let me explain. Given that my object is called O, it should support use as follows:
def tester(**kwargs):
print kwargs
tester(**O)
If Onot supported **, this would lead to a TypeError, for example. TypeError: test() argument after ** must be a mapping, not tuple.
This is a very simple scenario, but I need to know what Owill work before using it, and I must be absolutely sure that it will not fail. If I were testing Oin order to be iterable, I would use something like:
try:
iter(O)
except:
O = tuple()
Python, , ?
. , isinstance collections .
- ( )
try:
tester(**O)
except TypeError:
O = {}
python , iterables? , .
Edit
, isinstance, ...