Skip to content

The docstring of dict() should match the doc of dict() and it should be more understandable #137629

@hyperkai

Description

@hyperkai

The docstring of dict() doesn't match the doc of dict() and it isn't so understandable as shown below:

print(help(dict))
# class dict(object)
#  |  dict() -> new empty dictionary
#  |  dict(mapping) -> new dictionary initialized from a mapping object's
#  |      (key, value) pairs
#  |  dict(iterable) -> new dictionary initialized as if via:
#  |      d = {}
#  |      for k, v in iterable:
#  |          d[k] = v
#  |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
#  |      in the keyword argument list.  For example:  dict(one=1, two=2)

So, it should be like below:

dict(**kwargs) -> E.g. dict(key1=value1, key2=value2)
dict(mapping, **kwargs) -> mapping is the dictionary made by mapping object
dict(iterable, **kwargs) -> iterable is e.g. [('key1', 'value1'), ('key2', 'value2')]) treated by {k:v for k, v in iterable}

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirpendingThe issue will be closed if no feedback is provided

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions