-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·36 lines (24 loc) · 951 Bytes
/
run.py
File metadata and controls
executable file
·36 lines (24 loc) · 951 Bytes
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
#!/usr/bin/env python
"""Simple Fython demo
"""
from fython_test import callback_test, increase, mod_data
class Func:
# pylint: disable=too-few-public-methods
"""Class whose instances act like a function, i.e. are callables
https://docs.python.org/3/reference/datamodel.html?highlight=__call__#object.__call__
Called when the instance is “called” as a function; if this method is
defined, `x(arg1, arg2, ...)` is a shorthand for
`x.__call__(arg1, arg2, ...).`
"""
def __init__(self, val):
self.val = val
self.counter = 0
def __call__(self):
self.counter += 1
print(f'>>> Python: Called {self.counter} time')
print(f'>>> Python: Value {self.val}')
print(f'>>> Python: Number 1 in FORTRAN {mod_data.number1}')
print(f'>>> Python: Number 2 in FORTRAN {mod_data.number2}')
increase()
if __name__ == '__main__':
callback_test(Func(10))