Title: Include {name} in default format string · Issue #53 · realpython/codetiming · GitHub
Open Graph Title: Include {name} in default format string · Issue #53 · realpython/codetiming
X Title: Include {name} in default format string · Issue #53 · realpython/codetiming
Description: A small quality-of-life improvement would be if the default format string included the name attribute by default. >>> t = Timer('foobar') >>> t.start() >>> time.sleep(1) >>> t.stop() foobar elapsed time: 1.000 seconds >>> t = Timer() >>>...
Open Graph Description: A small quality-of-life improvement would be if the default format string included the name attribute by default. >>> t = Timer('foobar') >>> t.start() >>> time.sleep(1) >>> t.stop() foobar elapsed...
X Description: A small quality-of-life improvement would be if the default format string included the name attribute by default. >>> t = Timer('foobar') >>> t.start() >>> time.s...
Opengraph URL: https://github.com/realpython/codetiming/issues/53
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Include {name} in default format string","articleBody":"A small quality-of-life improvement would be if the default format string included the name attribute by default.\r\n\r\n``` python\r\n\u003e\u003e\u003e t = Timer('foobar')\r\n\u003e\u003e\u003e t.start()\r\n\u003e\u003e\u003e time.sleep(1)\r\n\u003e\u003e\u003e t.stop()\r\nfoobar elapsed time: 1.000 seconds\r\n\u003e\u003e\u003e t = Timer()\r\n\u003e\u003e\u003e t.start()\r\n\u003e\u003e\u003e time.sleep(1)\r\n\u003e\u003e\u003e t.stop()\r\nElapsed time: 1.000 seconds\r\n```\r\n\r\nThis might be achieved with the following `__post_init__` function:\r\n\r\n``` python\r\n def __post_init__(self):\r\n if self.name is None:\r\n self.text = \"Elapsed time: {:0.4f} seconds\"\r\n else:\r\n self.text = \"{name} elapsed time {:0.4f} seconds\"\r\n```\r\n\r\nAlternatively, name could just have a non-None default value (e.g. \"Timer\" or \"Elapsed\").","author":{"url":"https://github.com/Evidlo","@type":"Person","name":"Evidlo"},"datePublished":"2024-02-21T02:15:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/53/codetiming/issues/53"}
| 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:892d1476-35f5-57ca-369e-475860a869df |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFA2:27C649:1C3CF4:22BB8C:697FA470 |
| html-safe-nonce | 87c588a84f2deaa0f068d56cd30aea1ed045636f340d7eaf0f98b5d92b5a215b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkEyOjI3QzY0OToxQzNDRjQ6MjJCQjhDOjY5N0ZBNDcwIiwidmlzaXRvcl9pZCI6IjI0MjM2OTI1NTQxOTQxMDEzNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 604750b1a35ecfd25659fe81194da2cb73b6d2f61ceb93d71525805a57797c82 |
| hovercard-subject-tag | issue:2145640164 |
| 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/codetiming/53/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49682c91bb2748672de8202906b0605d033a63eee878f671e2f4a5dbfb2f35b6/realpython/codetiming/issues/53 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49682c91bb2748672de8202906b0605d033a63eee878f671e2f4a5dbfb2f35b6/realpython/codetiming/issues/53 |
| og:image:alt | A small quality-of-life improvement would be if the default format string included the name attribute by default. >>> t = Timer('foobar') >>> t.start() >>> time.sleep(1) >>> t.stop() foobar elapsed... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Evidlo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/realpython/codetiming git https://github.com/realpython/codetiming.git |
| octolytics-dimension-user_id | 5448020 |
| octolytics-dimension-user_login | realpython |
| octolytics-dimension-repository_id | 199325522 |
| octolytics-dimension-repository_nwo | realpython/codetiming |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 199325522 |
| octolytics-dimension-repository_network_root_nwo | realpython/codetiming |
| 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 | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width