You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify struct doc for format 's', when it is mentioned without numeric prefix #55645
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2011-07-17.09:32:24.973>created_at=<Date2011-03-07.18:29:36.358>labels= []
title="Clarify struct doc for format 's', when it is mentioned without numeric prefix"updated_at=<Date2011-07-17.09:32:24.971>user='https://github.com/terryjreedy'
changed the title [-]Clarify struct doc for format 's'.[/-][+]Clarify struct doc for format 's', when it is mentioned without numeric prefix[/+]on Jul 6, 2011
Those others field types have a standard or system-dependent fixed size and a number is an optional repeat count. Format 's' is always a single field because number prefix for that is special -- a field size.
"For the 's' format character, the count is interpreted as the length of the bytes, not a repeat count like for the other format characters; for example, '10s' means a single 10-byte string, while '10c' means 10 characters. "
I happen to think is could use a few more words of special explanation. Looking again, I think ", which defaults to 1" after the first 'count' above, would be sufficient. We nearly always docucument defaults.
Activity
terryjreedy commentedon Mar 7, 2011
The struct doc does not specify the meaning of 's', without a count. The attached patch adds the sentence:
If a count is not given, it defaults to 1;
's'means the same as'1s'.(Until I experimented, I had thought no count meant indefinite length).
terryjreedy commentedon Mar 7, 2011
patch
orsenthil commentedon Jul 6, 2011
Is this not implicit? Do we really need this stmt? I am -0 on this. If you agree, you can close this issue.
[-]Clarify struct doc for format 's'.[/-][+]Clarify struct doc for format 's', when it is mentioned without numeric prefix[/+]terryjreedy commentedon Jul 6, 2011
A default of 1 in not implicit for output formatting.
%s and {:s} mean however long needed, not %1s or {:1s}
orsenthil commentedon Jul 6, 2011
That is for the string formatting character, correct?
In this issue, we are talking about format character for struct and
not just 's' but 'c','h','b','i' all without numeric prefix imply
single value.
terryjreedy commentedon Jul 7, 2011
Those others field types have a standard or system-dependent fixed size and a number is an optional repeat count. Format 's' is always a single field because number prefix for that is special -- a field size.
"For the 's' format character, the count is interpreted as the length of the bytes, not a repeat count like for the other format characters; for example, '10s' means a single 10-byte string, while '10c' means 10 characters. "
I happen to think is could use a few more words of special explanation. Looking again, I think ", which defaults to 1" after the first 'count' above, would be sufficient. We nearly always docucument defaults.
python-dev commentedon Jul 17, 2011
New changeset 90cdf403132e by Senthil Kumaran in branch '3.2':
Fix closes bpo-11436 - Minor clarification to struct documentation for 's' format character.
http://hg.python.org/cpython/rev/90cdf403132e