-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Documentation
Currently, there are two different method signature style in builtin type str.
- The new style, marking the positional only parameters, like
zfill(self, width, /) - The old style, leading with
S., and should use an extra line to describe the signature.- Currently there are 9
S.started methods:count,endswith,find,format,format_map,index,rfind,rindexandstartswith.
- Currently there are 9
Example of new style and old style:
## New Style:
help(str.zfill)
# Help on method_descriptor:
#
# zfill(self, width, /)
# Pad a numeric string with zeros on the left, to fill a field of the given width.
#
# The string is never truncated.
## Old Style:
help(str.find)
# Help on method_descriptor:
#
# find(...)
# S.find(self, sub, start=None, end=None, /) -> int
#
# Return the lowest index in S where substring sub is found,
# such that sub is contained within S[start:end]. Optional
# arguments start and end are interpreted as in slice notation.
#
# Return -1 on failure.Suggestion
Change the 9 old style documentation to the new style:
count,endswith,find,format,format_map,index,rfind,rindexandstartswith.
Take str.find as an example, it would be more concise and consistent:
help(str.find)
# Help on method_descriptor:
#
# find(self, sub, start=None, end=None, /) -> int
#
# Return the lowest index in S where substring sub is found,
# such that sub is contained within S[start:end]. Optional
# arguments start and end are interpreted as in slice notation.
#
# Return -1 on failure.Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo