aboutsummaryrefslogtreecommitdiff
path: root/Python.wiki
blob: e221599ef0a95da1ab70228251a5c5d50e2c5d67 (plain)
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

== Imports are lazy ==

=== main.py ===
{{{python
import sys

match sys.argv:
    case [prgr]:
        print('Please give a sub-option')
    case [prgr, 'a', *args]:
        from a import x
        print(f'x = {x}')
    case [prgr, 'b', *args]:
        from b import x
        print(f'x = {x}')
}}}


=== a.py ===
{{{python
print('Importing a')
x = 10
}}}

=== b.py ===
{{{python
print('Importing b')
x = 20
}}}