Title: Allow specifying SimpleNamespace attributes as a mapping/iterable in a positional argument · Issue #108191 · python/cpython · GitHub
Open Graph Title: Allow specifying SimpleNamespace attributes as a mapping/iterable in a positional argument · Issue #108191 · python/cpython
X Title: Allow specifying SimpleNamespace attributes as a mapping/iterable in a positional argument · Issue #108191 · python/cpython
Description: Feature or enhancement Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse Links to previous discussion of this feature: #96145 https://mail.python.org/archives/list/python-dev@python.or...
Open Graph Description: Feature or enhancement Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse Links to previous discussion of this feature: #96145 https://mail.pytho...
X Description: Feature or enhancement Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse Links to previous discussion of this feature: #96145 https://mail.pytho...
Opengraph URL: https://github.com/python/cpython/issues/108191
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow specifying SimpleNamespace attributes as a mapping/iterable in a positional argument","articleBody":"# Feature or enhancement\r\n\r\n### Has this already been discussed elsewhere?\r\n\r\nI have already discussed this feature proposal on Discourse\r\n\r\n### Links to previous discussion of this feature:\r\n\r\nhttps://github.com/python/cpython/issues/96145\r\nhttps://mail.python.org/archives/list/python-dev@python.org/message/TYIXRGOLWGV5TNJ3XMV443O3RWLEYB65/\r\n\r\n### Proposal:\r\n\r\nIt was discussed in the context of adding controversial AttrDict. The reason for adding AttrDict was to allow JSON object attributes to be accessed as Python object attributes rather than dict keys. The reason for not using SimpleNamespace for this was that you need to use a wrapper `lambda x: SimpleNamespace(**x)`, which makes this solution less obvious.\r\n\r\nSupporting a positional argument in `SimpleNamespace()`, which can be a mapping or an iterable of key-value pairs (like in the `dict` constructor) will make using SimpleNamespace with JSON more convenient.\r\n\r\n`SimpleNamespace({'a': 1, 'b': 2})` is the same as `SimpleNamespace([('a', 1), ('b', 2)])` is the same as `SimpleNamespace(a=1, b=2)`.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-108195\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2023-08-21T07:30:51Z","url":"https://github.com/python/cpython/issues/108191"}
| 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:2fc98606-e49b-e7c9-ed80-b3d0233ed34c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD4C:3EB463:141CC6:1B2744:6B00644B |
| html-safe-nonce | 3c83eb2105b2cc5f831b10e9794b2c551b08e1721c31e9cb9c829a58eae9eb12 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDRDOjNFQjQ2MzoxNDFDQzY6MUIyNzQ0OjZCMDA2NDRCIiwidmlzaXRvcl9pZCI6IjIwNDA5OTg5MTY0Njc0ODM3MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9e061f59689e02537f63df111e141c0ddfe2b346e3f5e90bd5d5921fde501bff |
| hovercard-subject-tag | issue:1858777110 |
| 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/python/cpython/108191/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0b490de18889b80dafe51be455694ba26431b620b4e6d13ba00e407c622cc3e7/python/cpython/issues/108191 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0b490de18889b80dafe51be455694ba26431b620b4e6d13ba00e407c622cc3e7/python/cpython/issues/108191 |
| og:image:alt | Feature or enhancement Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse Links to previous discussion of this feature: #96145 https://mail.pytho... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 25854482a1773a7c1ebb8be3d2bc1c6e61d82d78126be63b5044474a86d44d9e |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | e4f5c239e31f1f680e6bbc419ff92d774da616ec |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width