This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| scripting:python [2023/08/10 07:29] – jotasandoku | scripting:python [2024/12/23 13:46] (current) – S jotasandoku | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| **__PYTHON__**\\ | **__PYTHON__**\\ | ||
| - | \\ | + | |
| + | |||
| + | == FOLLOW PYTHON CODE (WIP) === | ||
| + | |||
| + | This is just covering the simple case of an installed python program which is invoked via interactive cli.\\ | ||
| + | I take [[https:// | ||
| + | |||
| + | The executable archive for the main command (argv[0]) must be present in a location contained in ' | ||
| + | |||
| + | # | ||
| + | import netsim | ||
| + | import netsim.cli | ||
| + | netsim.cli.lab_commands(__file__) | ||
| + | |||
| + | '' | ||
| + | |||
| + | * Inside netsim/ | ||
| + | * we have the function '' | ||
| + | * the standard module '' | ||
| + | |||
| + | ---- | ||
| **Python virtual environment**: | **Python virtual environment**: | ||
| \\ | \\ | ||
| Line 139: | Line 160: | ||
| __**REGEX IN PYTHON**__ | __**REGEX IN PYTHON**__ | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * regex search ways in python: MATCH, SEARCH, FINDALL, and SUB | ||
| **__SEARCH__** | **__SEARCH__** | ||
| \\ | \\ | ||
| - | Tells us if the match is or isn' | + | A found 'yes or no'. Returns a Match object |
| txt = "The rain in Spain" | txt = "The rain in Spain" | ||
| Line 154: | Line 178: | ||
| vrf_dict = {name_match.group(" | vrf_dict = {name_match.group(" | ||
| | | ||
| + | |||
| \\ | \\ | ||
| - | \\ | + | **FINDALL: |
| - | * [[https:// | + | |
| - | * [[https:// | + | |
| - | * ALL INFO [[https:// | + | |
| - | * All regex can be done with or without [[https:// | + | |
| - | Resources | + | |
| - | https:// | + | |
| - | \\ | + | |
| - | regex search ways in python: MATCH, SEARCH, FINDALL, and SUB \\ | + | |
| - | \\ | + | |
| - | **FINDALL: | + | |
| - | re.findall( | + | |
| [' | [' | ||
| - | Example: find any serial number 8 characters long after the pattern: " | ||
| - | file = fileh.read() | ||
| - | serials = re.findall(r' | ||
| \\ | \\ | ||
| **SUB:** Can replace a parameter.\\ | **SUB:** Can replace a parameter.\\ | ||
| Line 318: | Line 330: | ||
| """ | """ | ||
| \\ | \\ | ||
| - | Slicing lists\\ | + | == SLICING === |
| - | print namelist[:2] | + | |
| + | # [:2] - First 2 elements | ||
| + | print("[:2] ->", | ||
| + | |||
| + | # [2:] - Everything from index 2 onwards | ||
| + | print(" | ||
| + | |||
| + | # [-2:] - Last 2 elements | ||
| + | print(" | ||
| + | |||
| + | # [:-2] - Everything EXCEPT last 2 elements | ||
| + | print(" | ||
| + | |||
| + | |||
| + | |||
| \\ | \\ | ||
| Updating list | Updating list | ||
| Line 809: | Line 836: | ||
| ---- | ---- | ||
| - | NGROK:\\ | + | NGROK: |
| + | \\ | ||
| * | * | ||
| Line 825: | Line 853: | ||
| __CODING NOTES__ | __CODING NOTES__ | ||
| * [[https:// | * [[https:// | ||
| - | * Use a 'list of unchecked cells'' | + | * Use a ''list of unchecked cells'' |
| pages_qty = len(page_numbers) + 1 | pages_qty = len(page_numbers) + 1 | ||
| Line 832: | Line 860: | ||
| + | |||
| + | ---- | ||
| + | TIME COMPLEXITY: | ||
| + | \\ | ||
| + | [[https:// | ||
| + | \\ | ||
| + | * Best case O(1) ; Worst case: O(n!) | ||
| ---- | ---- | ||
| Line 841: | Line 876: | ||
| * Moving-window average algorithm | * Moving-window average algorithm | ||
| * Sorted lists of numbers | * Sorted lists of numbers | ||
| + | |||
| + | |||