Skip to content

Instantly share code, notes, and snippets.

View nooperpudd's full-sized avatar

Winton nooperpudd

  • China
View GitHub Profile
@christoph2
christoph2 / structureWithEnums.py
Last active December 21, 2023 00:52
Add missing enum feature to ctypes Structures.
import ctypes
import enum
#
# Prerequisits:
# -------------
# If you are using Python < 3.4 run `pip install enum34`.
#
# Problem Definition
# ------------------
@leonmax
leonmax / exec.py
Last active September 12, 2021 20:15
sample to run subprocess and log stdout/stderr with asyncio
__author__ = 'leonmax'
import asyncio
from asyncio import (coroutine, subprocess)
import sys
import logging
FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.INFO, format=FORMAT)
@Zearin
Zearin / python_decorator_guide.md
Last active March 30, 2024 12:28
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@hrldcpr
hrldcpr / tree.md
Last active May 1, 2024 00:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!