Skip to content

Commit f43dea4

Browse files
committed
Modernize code
1 parent 631a0b3 commit f43dea4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

source-code/decorators/decorator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
class NegArgError(Exception):
77
def __init__(self, name, n):
8-
super(NegArgError, self).__init__()
8+
super().__init__()
99
self.message = 'argument {0} for {1} negative'.format(n, name)
1010

1111

1212
class TooLargeArgError(Exception):
1313
def __init__(self, name, n):
14-
super(TooLargeArgError, self).__init__()
14+
super().__init__()
1515
self.message = 'argument {0} for {1} too large'.format(n, name)
1616

1717

@@ -46,8 +46,8 @@ def fact(n):
4646
import sys
4747
for n in [3, 7, 22, -1]:
4848
try:
49-
print('{0}! = {1}'.format(n, fact(n)))
49+
print(f'{n}! = {fact(n)}')
5050
except Exception as error:
51-
sys.stderr.write('### error: {0}\n'.format(error))
52-
print('function name: {0}'.format(fact.__name__))
53-
print('function docs: {0}'.format(fact.__doc__))
51+
print(f'### error: {error.message}', file=sys.stderr)
52+
print(f'function name: {fact.__name__}')
53+
print(f'function docs: {fact.__doc__}')

0 commit comments

Comments
 (0)