Skip to content

Instantly share code, notes, and snippets.

View nagos's full-sized avatar

Vladimir Yakovlev nagos

View GitHub Profile
@nagos
nagos / listdir_test.py
Created October 26, 2022 13:52
Python dir listing without recursive functions
#!/usr/bin/env python3
import os
root_path = "/"
path_list = [root_path]
while len(path_list):
path = path_list.pop()
try:
#!/usr/bin/env python3
# https://docs.python.org/3/library/sqlite3.html
import sqlite3
con = sqlite3.connect("tutorial.db")
cur = con.cursor()
cur.execute("CREATE TABLE movie(title, year, score)")
cur.execute("""
@nagos
nagos / Dockerfile
Last active February 10, 2023 12:29
Python docker starter package
FROM python:3
WORKDIR /usr/src/app
# COPY requirements.txt ./
# RUN pip install --no-cache-dir -r requirements.txt
COPY hello.py .
CMD ["python", "./hello.py"]
def calc(x):
print("-- Calculating")
try:
result = 5 / x
except ZeroDivisionError:
print("-- Expected error, continue")
result = 0
print("-- Result ready")
return result