This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openpyxl import Workbook | |
text = "" # Including three bytes: hexadecimal FFBFBF resulting ValueError | |
# text = '\x16' # resulting IllegalCharacterError | |
wb = Workbook() | |
ws = wb.active | |
ws.append([text]) | |
wb.save("test.xlsx") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've just returned from EuroPython Conference, and there was a good presentation: "From Jupyter Notebooks to a Python Package: The Best of Both Worlds". If I'm correct the video is not (yet?) on youtube, but the repo and the slides are here. | |
https://github.com/sesise0307/europython2023-package | |
I've used to use a similar setup, but I'll do the same (just w/ PyCharm instead of VSCode). | |
Creating packag(es) from frequently used functionalities. | |
%load_ext autoreload%autoreload 2 | |
in Jupyter, and then from Jupyter (starting with !) or from commandline | |
pip install --editable <path> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fnmatch | |
import os | |
import sys | |
from pathlib import Path | |
eleresi_ut = Path.home() / "Documents" | |
minta = 'Co*t*.*' | |
# good old walk | |
for root, dirs, files in os.walk(eleresi_ut): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from test_cases import cases | |
from irish_possessive_golf import f | |
def test_all(): | |
for i, (x, y, result) in enumerate(cases): | |
my_result = f(x, y) | |
assert my_result == result, f"{x}, {y} should give {result}, not {my_result} ({i+1})" | |
print("All succeeded") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from pathlib import Path | |
import os | |
def get_latest_file(directory: Path) -> Path: | |
""" | |
Finds the most recently modified file in a directory and its subdirectories. | |
Args: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Solution for | |
https://adventofcode.com/2022/day/2 | |
first and second half | |
""" | |
from typing import List, Callable | |
RESULT_SCORES = {"draw": 3, "win": 6, "loose": 0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
import turtle | |
window = turtle.Screen() | |
def draw_polygon(sides, color): | |
turtle.color(color) | |
angle = 360/sides | |
for i in range(sides): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
from microbit import * | |
s3 = sqrt(3) | |
pattern0 = [(1, 1), (-1, -1), (-s3, s3)] | |
def magnify_by(n): | |
def transf(x, y): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ebből indulva https://pastebin.com/raw/nPbzGFmu | |
az eredmény: | |
Szakasz: Tulajdonosi adatok | |
{'Tul.hányad': '1/2', 'Szerz.jogcím': 'adásvétel', 'Név': 'Gipsz Csaba', 'Anyja neve': 'Próba Katalin', 'Jogállás': 'tulajdonos', 'Cím': '4965 MINTA, Kölcsey utca 105'} | |
{'Tul.hányad': '1/2', 'Szerz.jogcím': 'adásvétel', 'Név': 'Gipsz Csabáné', 'Szül.név': 'Gipsz Éva', 'Anyja neve': 'Minta Borbála', 'Jogállás': 'tulajdonos', 'Cím': '4965 MINTA, Kölcsey utca 105'} | |
Szakasz: Jogok-tények jogosultjai | |
{'Jog-tény neve': 'Önálló szöveges bejegyzés', 'Szöveg': 'Lakcímváltozás átvezetése.'} | |
{'Jog-tény neve': 'Jelzálogjog', 'Név': 'MAGYAR ÁLLAM', 'Cím': '-,'} | |
{'Jog-tény neve': 'Elidegenítési és terhelési tilalom', 'Név': 'MAGYAR ÁLLAM', 'Cím': '-,', 'Utalások': 'III/14'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Callable, Union | |
from pyrsistent import PVector, PMap, ny, freeze | |
def loose_transform(structure: Union[PVector,PMap], path: List, command: Callable): | |
if not path: | |
return command(structure) if callable(command) else command | |
key_spec = path[0] | |
if not callable(key_spec): |
NewerOlder