Skip to content

Update documention of stdlib copy to clear that list can also be shallow copied via .copy()#131027

Closed
NewUserHa wants to merge 1 commit into
python:mainfrom
NewUserHa:patch-6
Closed

Update documention of stdlib copy to clear that list can also be shallow copied via .copy()#131027
NewUserHa wants to merge 1 commit into
python:mainfrom
NewUserHa:patch-6

Conversation

@NewUserHa
Copy link
Copy Markdown
Contributor

@NewUserHa NewUserHa commented Mar 9, 2025

Update documention of stdlib copy to clear that list can also be shallow copied via .copy()

a = [1,2]
b = a.copy()
b

this can work in recent versions of python


📚 Documentation preview 📚: https://cpython-previews--131027.org.readthedocs.build/

Comment thread Doc/library/copy.rst

Shallow copies of dictionaries can be made using :meth:`dict.copy`, and
of lists by assigning a slice of the entire list, for example,
Shallow copies of dictionaries and lists can be made using :meth:`dict.copy`. And
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now links to dict.copy for both a dicts and lists?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it means dict type and list type, .copy() is both their built-in method

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 22, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 14, 2026
@serhiy-storchaka
Copy link
Copy Markdown
Member

See #150637.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants