Title: Instantiate and start timer on single line · Issue #52 · realpython/codetiming · GitHub
Open Graph Title: Instantiate and start timer on single line · Issue #52 · realpython/codetiming
X Title: Instantiate and start timer on single line · Issue #52 · realpython/codetiming
Description: It would be helpful if there was a way to start the timer when it is instantiated, such as t = Timer().start() or t = Timer(now=True). This can reduce the number of required lines from 3 to 2 which is nice when inserting many timers. t =...
Open Graph Description: It would be helpful if there was a way to start the timer when it is instantiated, such as t = Timer().start() or t = Timer(now=True). This can reduce the number of required lines from 3 to 2 which...
X Description: It would be helpful if there was a way to start the timer when it is instantiated, such as t = Timer().start() or t = Timer(now=True). This can reduce the number of required lines from 3 to 2 which...
Opengraph URL: https://github.com/realpython/codetiming/issues/52
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Instantiate and start timer on single line","articleBody":"It would be helpful if there was a way to start the timer when it is instantiated, such as `t = Timer().start()` or `t = Timer(now=True)`.\r\n\r\nThis can reduce the number of required lines from 3 to 2 which is nice when inserting many timers.\r\n\r\n``` python\r\nt = Timer().start()\r\n# code block 1\r\nt.stop()\r\n\r\nt = Timer().start()\r\n# code block 2\r\nt.stop()\r\n\r\nt = Timer().start()\r\n# code block 3\r\nt.stop()\r\n```\r\n\r\nTo do this, either `.start()` would need to return `self` or a `Timer.__post_init__` function would need to if `self.now == True`.","author":{"url":"https://github.com/Evidlo","@type":"Person","name":"Evidlo"},"datePublished":"2024-02-21T01:57:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/52/codetiming/issues/52"}
| 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:2b4eb04a-8eb7-44a1-650a-6bfe8e94e9c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A8CA:3AA924:1A3A93F:22080DC:697FB499 |
| html-safe-nonce | d81d75bf08855ec6e48f6b8a5098ae7d8c3e3eef7b41c0777aeb14b922c31dae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOENBOjNBQTkyNDoxQTNBOTNGOjIyMDgwREM6Njk3RkI0OTkiLCJ2aXNpdG9yX2lkIjoiNDk1MzM1NDAxNDM3MzY4ODQ3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5fbcab698f2c433cf9cee15d14c80952d0ee430fe6bd09372905d03e18abcbbf |
| hovercard-subject-tag | issue:2145621679 |
| 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/52/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eeb39d6e4b7c8d3babce932fec7045040fd49958174285e2609108dc8f6e2325/realpython/codetiming/issues/52 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eeb39d6e4b7c8d3babce932fec7045040fd49958174285e2609108dc8f6e2325/realpython/codetiming/issues/52 |
| og:image:alt | It would be helpful if there was a way to start the timer when it is instantiated, such as t = Timer().start() or t = Timer(now=True). This can reduce the number of required lines from 3 to 2 which... |
| 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