File: head_recursion.py

package info (click to toggle)
loguru 0.7.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,568 kB
  • sloc: python: 13,164; javascript: 49; makefile: 14
file content (42 lines) | stat: -rw-r--r-- 466 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys

from loguru import logger

logger.remove()
logger.add(sys.stderr, format="", colorize=False, backtrace=True, diagnose=False)


@logger.catch()
def a(n):
    if n:
        a(n - 1)
    1 / n


def b(n):
    if n:
        with logger.catch():
            b(n - 1)
    1 / n


def c(n):
    if n:
        try:
            c(n - 1)
        except ZeroDivisionError:
            logger.exception("")
    1 / n


a(1)
a(2)
a(3)

b(1)
b(2)
b(3)

c(1)
c(2)
c(3)