Is it possible to use a function with a dict argument which has other argument like p2
in it?
def f(l, p2, p = {"t": p2}):
print(l)
f(12, 13)
Is it possible to use a function with a dict argument which has other argument like p2
in it?
def f(l, p2, p = {"t": p2}):
print(l)
f(12, 13)
No. The dict {"t": p2}
is created at function definition, at which time p2
is not bound to anything.
What you can do is
def f(l, p2, p=None):
if p is None:
p = {'t': p2}
# rest of code