D
D
Dream2021-10-07 13:25:33
Python
Dream, 2021-10-07 13:25:33

How to pass only 1 argument out of 3?

There are 3 arguments in the function, is it possible to pass 1 desired argument without the other 2 without using None. I want to transfer the message text from 1 function to another and I don't know how to transfer the text.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ronald McDonald, 2021-10-07
@Zoominger

Yes, as long as the parameters you won't pass have default values ​​defined.

N
Nikolay Savelyev, 2021-10-07
@AgentSmith

If a function asks for three arguments, then it must be passed three arguments.
Either redefine the function or mark arguments as optional or with default values

V
Vladimir Kuts, 2021-10-08
@fox_12

They would give an example, otherwise it’s not entirely clear what you want ...
You can use partial as an option

from functools import partial

def test(x, y, z):
    print(x, y, z)
    
test1 = partial(test, '', '')

test1(7)
# 7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question