5 kyu
Context manager decorator
129Dundee
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
the link in the description points to the docs for Python 2.7, which is quite ancient. it should be upgraded to more recent docs
Hello There, i am trying to do this kata but get stuck on when the with statement is executed
i am not able to get to the enter method, even if i do my custom contextmanager...
is there any tips you can provide ?
The initial code for the kata is this:
which is misleading and wrong: context manager is only used as
@contextmanager
sowrapper
should not have any arguments. The actual parameters are passed in later to the thing returned from the wrapper.You are probably mixing together decorator taking args and not taking args. You would be right, if contextmanager would be called as a function, like this:
However, you have to take args and kwargs in the wrapper if you use the decorator without args:
This kata needs random tests.
This comment has been hidden.
Really nice kata. would be nice if there were more test cases
This comment has been hidden.
Sure. It's in the description as well.
From the description it looks like the task is to implement it rather than to provide a working implementation with or without really reimplementing it...
needing a forbidder?
Kata updated, contextlib is now forbidden.
@Unnamed: could you rerank/revote according to the current situation?
There could be more test cases, at least for nonempty function arguments.
Thanks for this Kata. It's good to be aware of these possibilities!
This comment has been hidden.
True story.