Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Let's say this is the signature of my function:
def foo(x,y,z=0): . .
When I want to use this function, how can I override the value of z without changing the function or the signature?
z
def bar(x,y,z=5): return foo(x,y,z)
foo
Just pass value explicitly.
def foo(x, y, z=0): print z foo(1,3) >> 0 # default value foo(1,2,5) >> 5 # new value passed
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
zwhen calling the function?def bar(x,y,z=5): return foo(x,y,z)?foowith a different default that calls the old function object. Would that do?