Then you can say:
is_(x).a_number()
is_(x).an_instance_of(y)
Or you could also do:
@curry_helper
def insert(arg):
... # elsewhere
@insert.add_predicate
def into(obj, cls):
if not isinstance(obj, cls):
raise TypeError(f"{type(obj).__qualname__}")
@insert.into.add_predicate(obj='m', cls=MutableMapping)
def mapping(k, v, m):
if k in m:
raise KeyError(f"{k!r} already exists")
m[k] = v
@insert.add_predicate(obj='s', cls=MutableSequence)
def seq(x, s):
... # elsewhere
@insert.seq.add_predicate(x='x', s='s')
def at(x, s, i):
s.insert(i, x)
The idea there would be to provide a way to pass arguments to parent functions, and then:
insert(x).into.seq(s).at(i)
insert(k, v).into.mapping(m)
I would never use any of this in a serious application, but it's still fun.
---
Ricky.
"I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler