|
| 1 | +# < definition scip-python python snapshot-util 0.1 walrus/__init__: |
| 2 | +#documentation (module) walrus |
| 3 | + |
| 4 | +import re |
| 5 | +# ^^ reference python-stdlib 3.11 re/__init__: |
| 6 | + |
| 7 | +some_list = [1, 2, 3, 4, 5, 100, 1000] |
| 8 | +#^^^^^^^^ definition snapshot-util 0.1 walrus/some_list. |
| 9 | +#documentation ```python |
| 10 | +# > builtins.list |
| 11 | +# > ``` |
| 12 | +pattern = "^[A-Za-z0-9_]*$" |
| 13 | +#^^^^^^ definition snapshot-util 0.1 walrus/pattern. |
| 14 | +#documentation ```python |
| 15 | +# > builtins.str |
| 16 | +# > ``` |
| 17 | +text = "Some_name123" |
| 18 | +#^^^ definition snapshot-util 0.1 walrus/text. |
| 19 | +#documentation ```python |
| 20 | +# > builtins.str |
| 21 | +# > ``` |
| 22 | + |
| 23 | +# if statement |
| 24 | +if (n := len(some_list)) > 10: |
| 25 | +# ^ definition snapshot-util 0.1 walrus/n. |
| 26 | +# ^^^ reference local 0 |
| 27 | +# external documentation ```python |
| 28 | +# > (function) def len( |
| 29 | +# > __obj: Sized, |
| 30 | +# > / |
| 31 | +# > ) -> int |
| 32 | +# > ``` |
| 33 | +# ^^^^^^^^^ reference snapshot-util 0.1 walrus/some_list. |
| 34 | + print(f"List is too long with {n} elements.") |
| 35 | +# ^^^^^ reference python-stdlib 3.11 builtins/print(). |
| 36 | +# external documentation ```python |
| 37 | +# > (function) def print( |
| 38 | +# > *values: object, |
| 39 | +# > sep: str | None = " ", |
| 40 | +# > end: str | None = "\n", |
| 41 | +# > file: SupportsWrite[str] | None = No... |
| 42 | +# > flush: Literal[False] = False |
| 43 | +# > ) -> None |
| 44 | +# > ``` |
| 45 | +# ^ reference snapshot-util 0.1 walrus/n. |
| 46 | + |
| 47 | +if (match := re.search(pattern, text)) is not None: |
| 48 | +# ^^^^^ definition snapshot-util 0.1 walrus/match. |
| 49 | +# ^^ reference python-stdlib 3.11 re/__init__: |
| 50 | +# ^^^^^^ reference python-stdlib 3.11 re/search(). |
| 51 | +# ^^^^^^^ reference snapshot-util 0.1 walrus/pattern. |
| 52 | +# ^^^^ reference snapshot-util 0.1 walrus/text. |
| 53 | + print("Found match:", match.group(0)) |
| 54 | +# ^^^^^ reference python-stdlib 3.11 builtins/print(). |
| 55 | +# ^^^^^ reference snapshot-util 0.1 walrus/match. |
| 56 | +# ^^^^^ reference python-stdlib 3.11 re/Match#group(). |
| 57 | + |
| 58 | + |
| 59 | +# comprehensions |
| 60 | +def show_some_comprehension(): |
| 61 | +# ^^^^^^^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 walrus/show_some_comprehension(). |
| 62 | +# documentation ```python |
| 63 | +# > def show_some_comprehension(): # -> None... |
| 64 | +# > ``` |
| 65 | + [print(x, root) for x in some_list if (x % 2 == 0) and (root := x**0.5) > 5] |
| 66 | +# ^^^^^ reference python-stdlib 3.11 builtins/print(). |
| 67 | +# ^ reference local 1 |
| 68 | +# ^^^^ reference local 2 |
| 69 | +# ^ definition local 1 |
| 70 | +# documentation ```python |
| 71 | +# > (variable) x: int |
| 72 | +# > ``` |
| 73 | +# ^^^^^^^^^ reference snapshot-util 0.1 walrus/some_list. |
| 74 | +# ^ reference local 1 |
| 75 | +# ^^^^ definition local 2 |
| 76 | +# ^ reference local 1 |
| 77 | + |
| 78 | + |
| 79 | +# while loop |
| 80 | +while (line := input("Enter text: ")) != "quit": |
| 81 | +# ^^^^ definition snapshot-util 0.1 walrus/line. |
| 82 | +# ^^^^^ reference local 3 |
| 83 | +# external documentation ```python |
| 84 | +# > (function) def input( |
| 85 | +# > __prompt: object = "", |
| 86 | +# > / |
| 87 | +# > ) -> str |
| 88 | +# > ``` |
| 89 | + print(f"You entered: {line}") |
| 90 | +# ^^^^^ reference python-stdlib 3.11 builtins/print(). |
| 91 | +# ^^^^ reference snapshot-util 0.1 walrus/line. |
| 92 | + |
| 93 | + |
| 94 | +# if + comprehension |
| 95 | +if any((any_n := num) < 0 for num in some_list): |
| 96 | +# ^^^ reference local 4 |
| 97 | +# external documentation ```python |
| 98 | +# > (function) def any( |
| 99 | +# > __iterable: Iterable[object], |
| 100 | +# > / |
| 101 | +# > ) -> bool |
| 102 | +# > ``` |
| 103 | +# ^^^^^ definition any_n. |
| 104 | +# ^^^ reference local 5 |
| 105 | +# ^^^ definition local 5 |
| 106 | +# documentation ```python |
| 107 | +# > (variable) num: int |
| 108 | +# > ``` |
| 109 | +# ^^^^^^^^^ reference snapshot-util 0.1 walrus/some_list. |
| 110 | + print(f"Negative number found: {any_n}") |
| 111 | +# ^^^^^ reference python-stdlib 3.11 builtins/print(). |
| 112 | +# ^^^^^ reference any_n. |
| 113 | + |
0 commit comments