Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Request for review: Decorator implementation example #134500

Closed as not planned
Closed as not planned
@ShengDong207

Description

@ShengDong207

I'm learning about Python decorators and would appreciate feedback on my implementation.

Here's my example code:

@timer
def slow_function():
    import time
    time.sleep(2)
    return "Done"

Specifically, I'd like to know:

  1. Is this a correct usage of decorators?
  2. What's missing from the implementation (I notice the @timer decorator itself isn't defined)
  3. Best practices for implementing timing decorators

Thank you for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions