Author terry.reedy
Recipients Julian, docs@python, terry.reedy, yselivanov
Date 2020-09-12.00:18:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599869908.77.0.158760042416.issue41745@roundup.psfhosted.org>
In-reply-to
Content
Bound is created with 5 public attributes:
>>> dir(bound)
[..., 'apply_defaults', 'args', 'arguments', 'kwargs', 'signature']
>>> bound.args
()
>>> bound.arguments
{}
>>> bound.kwargs
{}
msg376578: I don't understand 'non-existent' arguments,  Nor 'what happened...print... ignored' as there is no previous print.

msg376590: Given " Changes in arguments will reflect in args and kwargs.", I agree that changes to 'arguments' *apparently* not being reflected in 'args' and 'kwargs' is initally a bit puzzling
.
>>> bound.kwargs == bound.arguments
True
>>> bound.arguments['something'] = 'guess'
>>> bound.kwargs
{}
>>> bound.arguments
{'something': 'guess'}

However, your 'two' function takes no arguments, so valid values of args and kwargs must be empty for them to be used in a call.  In all cases, args() and kwargs() must look at the signature to see which key-value pairs they should extract from arguments.

>>> def f(a): pass

>>> signature(f).bind()  # Must pass value arguments
Traceback (most recent call last):
...
TypeError: missing a required argument: 'a'
>>> b = signature(f).bind(3)
>>> b.arguments
{'a': 3}
>>> b.args
(3,)  # Because 'a' is positional.
>>> b.kwargs
{}  # Because 'a' is not keyword only.
>>> b.arguments['a']=5
>>> b.args
(5,)  # Legitimate change reflected here.

Perhaps the doc could be improved, but I have no particular suggestion.
History
Date User Action Args
2020-09-12 00:18:28terry.reedysetrecipients: + terry.reedy, docs@python, Julian, yselivanov
2020-09-12 00:18:28terry.reedysetmessageid: <1599869908.77.0.158760042416.issue41745@roundup.psfhosted.org>
2020-09-12 00:18:28terry.reedylinkissue41745 messages
2020-09-12 00:18:28terry.reedycreate