Ad
  • Custom User Avatar

    Approved.

  • Custom User Avatar

    python new test framework is required. updated in this fork

  • Custom User Avatar

    Description says "Only positives integers will be used", yet 0 is generated sometimes.

  • Custom User Avatar

    I have learned few new things about python while solving. Good kata!

  • Custom User Avatar

    Im not at this top level stuff but how do you access the Foo() class within the test cases? If I try making my own it doesn't work as the test cases require the class object specifically initilized within the test cases its self.

  • Default User Avatar

    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

  • Default User Avatar

    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 ?

  • Custom User Avatar

    My solution works locally, but fails when submitted.

  • Custom User Avatar

    This was a great kata, overall.

    But I would definitely write up some more tests that include other classes being inherited by base classes.

    for example.

    class Person(metaclass = Meta):
        def __init__(self, name):
            self.name = name
    
        def getName(self):
            return self.name
    
    class Bob(Person):
        def __init__(self):
            self.n = 1
            super().__init__('Bob')
    
        def bob_get(self):
            return self.n
    
    
    b = Bob() # should register two __init__ calls
    b.a = 2 # set
    b.a # get
    b.bob_get() # get for 'n' along with get for method call and method call itself
    

    There is a solution that passes your tests but doesn't pass this one so I had to improve the solution.

    So to prevent the incomplete or incorrect code from passing and making this kata a bit more complete, I would add up those tests.

    Regardless of that - Excellent stuff!

  • Default User Avatar

    Really enjoyed this Kata! Metaclasses are so cool. Thanks!

  • Custom User Avatar

    This kata is amazing and I learned a lot about Metaclass. Thanks!

  • Custom User Avatar

    Ranks can't be changed.

  • Custom User Avatar

    Kata is nice, but compaired to other 4 kyu's I've tried it is too simple. Maybe move to 5 kyu?

  • Custom User Avatar

    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:

    def some_decorator(some_arg=None):
        def inner(func):
            def wrapper(*args, **kwargs):
                ...
                return func(*args, **kwargs)
            return wrapper
        return inner
    
    @some_decorator()  # note the parentheses
    def foo(x):
        print(x)
    
    foo('aaa')
    

    However, you have to take args and kwargs in the wrapper if you use the decorator without args:

    def some_decorator(func):
        def wrapper(*args, **kwargs):
            ...
            return func(*args, **kwargs)
        return wrapper
    
    @some_decorator  # no parentheses
    def foo(x):
        print(x)
    
    foo('aaa')
    
  • Custom User Avatar

    The initial code for the kata is this:

    def contextmanager(f):
        def wrapper(*args, **kwargs):
            # your solution
        return wrapper
    

    which is misleading and wrong: context manager is only used as @contextmanager so wrapper should not have any arguments. The actual parameters are passed in later to the thing returned from the wrapper.

  • Loading more items...