0

Can I call a function using the default value for some arguments but not for all?

Take numpy.random.lognormal(mean=0.0, sigma=1.0, size=None) as an example, I want to call it with default mean and sigma but not default size.

Something in my mind is like np.random.lognormal(_,_,2), but this does not work

Is it possible to do that?

1 Answer 1

2

Yes, this is possible. Simply provide the argument you want to override:

np.random.lognormal(size=2)

This is precisely where named arguments become useful.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.