Title: Problem with make function on page 843 · Issue #47 · fluentpython/example-code-2e · GitHub
Open Graph Title: Problem with make function on page 843 · Issue #47 · fluentpython/example-code-2e
X Title: Problem with make function on page 843 · Issue #47 · fluentpython/example-code-2e
Description: I believe the pseudocode for object construction on page 843 is somewhat misleading: def make(the_class, some_arg): new_object = the_class.__new__(some_arg) if isinstance(new_object, the_class): the_class.__init__(new_object, some_arg) r...
Open Graph Description: I believe the pseudocode for object construction on page 843 is somewhat misleading: def make(the_class, some_arg): new_object = the_class.__new__(some_arg) if isinstance(new_object, the_class): th...
X Description: I believe the pseudocode for object construction on page 843 is somewhat misleading: def make(the_class, some_arg): new_object = the_class.__new__(some_arg) if isinstance(new_object, the_class): th...
Opengraph URL: https://github.com/fluentpython/example-code-2e/issues/47
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Problem with make function on page 843","articleBody":"I believe the pseudocode for object construction on page 843 is somewhat misleading:\r\n\r\n```python\r\ndef make(the_class, some_arg):\r\n new_object = the_class.__new__(some_arg)\r\n if isinstance(new_object, the_class):\r\n the_class.__init__(new_object, some_arg)\r\n return new_object\r\n```\r\n\r\nFirstly, it doesn't function correctly even in the simplest case. `the_class.__new__(some_arg)` should be called as `the_class.__new__(the_class, some_arg)` for proper operation. Secondly, it lacks generality. I suggest the following code as a more suitable replacement:\r\n\r\n```python\r\ndef make(the_class, *args, **kwargs):\r\n new_object = the_class.__new__(the_class, *args, **kwargs)\r\n if isinstance(new_object, the_class):\r\n the_class.__init__(new_object, *args, **kwargs)\r\n return new_object\r\n```","author":{"url":"https://github.com/kamalfarahani","@type":"Person","name":"kamalfarahani"},"datePublished":"2024-10-30T12:22:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/47/example-code-2e/issues/47"}
| 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:09f5d162-f620-c959-212c-12b9e6c9b888 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF08:3B9F32:8A066F:C28883:69725080 |
| html-safe-nonce | d885e65a0d55d09a635f764e73a03dfc62feb76c4c4629fe872665afb91aed01 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjA4OjNCOUYzMjo4QTA2NkY6QzI4ODgzOjY5NzI1MDgwIiwidmlzaXRvcl9pZCI6IjI3NzU0OTA0NjA2NjU0MDE0NzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3dbbd54d84e6b371a4e9ec21802adc3b7367a6524a9ea9977f577d21b683c866 |
| hovercard-subject-tag | issue:2623930491 |
| 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/fluentpython/example-code-2e/47/issue_layout |
| twitter:image | https://opengraph.githubassets.com/19c012931820b3010eff728dcb84cc8b3105f824adc5728681dcb4cfdc8268ba/fluentpython/example-code-2e/issues/47 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/19c012931820b3010eff728dcb84cc8b3105f824adc5728681dcb4cfdc8268ba/fluentpython/example-code-2e/issues/47 |
| og:image:alt | I believe the pseudocode for object construction on page 843 is somewhat misleading: def make(the_class, some_arg): new_object = the_class.__new__(some_arg) if isinstance(new_object, the_class): th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kamalfarahani |
| hostname | github.com |
| expected-hostname | github.com |
| None | f6d9b08324bb62b2cf170b9e435da2bdc7efa5aa93e7ca70ee3162552c05329b |
| turbo-cache-control | no-preview |
| go-import | github.com/fluentpython/example-code-2e git https://github.com/fluentpython/example-code-2e.git |
| octolytics-dimension-user_id | 9216311 |
| octolytics-dimension-user_login | fluentpython |
| octolytics-dimension-repository_id | 176997413 |
| octolytics-dimension-repository_nwo | fluentpython/example-code-2e |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 176997413 |
| octolytics-dimension-repository_network_root_nwo | fluentpython/example-code-2e |
| 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 | 169d2b5c72bff9cc676084f0ac7f8ea888f15f54 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width