Title: Code Style - not really good list manipulation example - needs explanation · Issue #1086 · realpython/python-guide · GitHub
Open Graph Title: Code Style - not really good list manipulation example - needs explanation · Issue #1086 · realpython/python-guide
X Title: Code Style - not really good list manipulation example - needs explanation · Issue #1086 · realpython/python-guide
Description: In the Code Style chapter examples - Short Ways to Manipulate Lists there is an example "Add three to all list members." "bad" for i in range(len(a)): a[i] += 3 "good" a = [i + 3 for i in a] Unfortunately the "bad" and "good" examples do...
Open Graph Description: In the Code Style chapter examples - Short Ways to Manipulate Lists there is an example "Add three to all list members." "bad" for i in range(len(a)): a[i] += 3 "good" a = [i + 3 for i in a] Unfort...
X Description: In the Code Style chapter examples - Short Ways to Manipulate Lists there is an example "Add three to all list members." "bad" for i in range(len(a)): a[i] += 3 "good"...
Opengraph URL: https://github.com/realpython/python-guide/issues/1086
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Code Style - not really good list manipulation example - needs explanation","articleBody":"In the Code Style chapter examples - [Short Ways to Manipulate Lists](https://python-docs.readthedocs.io/en/latest/writing/style.html#short-ways-to-manipulate-lists) there is an example \"Add three to all list members.\"\r\n\r\n\"bad\"\r\n```python\r\nfor i in range(len(a)):\r\n a[i] += 3\r\n```\r\n\r\n\"good\"\r\n```python\r\na = [i + 3 for i in a]\r\n```\r\n\r\nUnfortunately the \"bad\" and \"good\" examples do a different things:\r\n* \"bad\" modifies the original list in place\r\n* \"good\" creates a new modified list and does not change the original object - not exactly \"Add three to all list members.\"\r\n\r\nAlthough the \"good\" code looks cleaner the result could be unwanted for example in case of huge lists or required side-effect of modifying the original list. The code at least needs an explanation.","author":{"url":"https://github.com/vbrozik","@type":"Person","name":"vbrozik"},"datePublished":"2021-01-06T22:50:27Z","url":"https://github.com/realpython/python-guide/issues/1086"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ad70954b-02a5-b2f2-1ad8-e74ea426339a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BFF0:0DF6:1828ABD:20019DF:6B067700 |
| html-safe-nonce | b200a160057a22b1697490d1a8119b4de3ec983d136adbf5fdfb7977e44c5df6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkYwOjBERjY6MTgyOEFCRDoyMDAxOURGOjZCMDY3NzAwIiwidmlzaXRvcl9pZCI6IjcyMzcxNjcxNDMxOTQ3NjQ4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6116de28f94bd8d632e5a46285783ee99ad9d85c689995828e346cac8b102496 |
| hovercard-subject-tag | issue:780896411 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/realpython/python-guide/1086/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0730acd4b105a8ce4778dcdf5650270e882d95203c1a8e40fa0e4a4bac7da915/realpython/python-guide/issues/1086 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0730acd4b105a8ce4778dcdf5650270e882d95203c1a8e40fa0e4a4bac7da915/realpython/python-guide/issues/1086 |
| og:image:alt | In the Code Style chapter examples - Short Ways to Manipulate Lists there is an example "Add three to all list members." "bad" for i in range(len(a)): a[i] += 3 "good" a = [i + 3 for i in a] Unfort... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vbrozik |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a |
| turbo-cache-control | no-preview |
| go-import | github.com/realpython/python-guide git https://github.com/realpython/python-guide.git |
| octolytics-dimension-user_id | 5448020 |
| octolytics-dimension-user_login | realpython |
| octolytics-dimension-repository_id | 1481305 |
| octolytics-dimension-repository_nwo | realpython/python-guide |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1481305 |
| octolytics-dimension-repository_network_root_nwo | realpython/python-guide |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6d3909414814ff86ce7da4c51a0f4918a13fb41b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width