Implementation of enter, before, exec, after, leave, methods in Generator