classDiagram
class Message {
time: float
is_forwarded: bool
handler_name: str
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 functools | |
import itertools | |
from collections.abc import Iterator | |
def is_multiple_of(p: int, x: int) -> bool: | |
# if x % p == 0: | |
# print("discarding", x, "multiple of", p) | |
return x % p == 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
# Demonstrates that setting the log level in a handler overrides any setting of log level in the logger | |
# | |
# The purpose of this is to support adding handlers that take extra action or route log messages to other | |
# destinations for any logs at higher levels. For instance, creating and adding a handler to the root | |
# logger where the handler's level is set to ERROR, and streams its logs to a notification service queue. | |
# Even if the logger's level is set to a lower level of logging, the specialized handler only routes | |
# ERROR or higher log messages to the notification service. | |
# | |
# The problem arises if the handler that is set to a particular log level is the root logger's sole | |
# stdout handler. In this case, it becomes difficult to change the log level on the logger, because the |
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
# remove pesky trailing newlines from iterating over a text file | |
def denewlining(line_iterator): | |
for line in line_iterator: | |
yield line.rstrip("\n\r") | |
with open(__file__) as infile: | |
for line in denewlining(infile): | |
print(f"{line!r} <-- look ma! no trailing newlines!") |
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 contextlib | |
class InvalidStateActionError(NotImplementedError): | |
pass | |
class InvalidStateTransitionError(InvalidStateActionError): | |
pass |
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
[ | |
{"id": "1", "title": "PEP Purpose and Guidelines", "authors": "Warsaw, Hylton, Goodger, Coghlan", "discussions_to": null, "status": "Active", "type": "Process", "topic": "", "created": "13-Jun-2000", "python_version": null, "post_history": "21-Mar-2001, 29-Jul-2002, 03-May-2003, 05-May-2012, 07-Apr-2013", "resolution": null, "requires": null, "replaces": null, "superseded_by": null, "url": "https://peps.python.org/pep-0001/", "abstract": ""}, | |
{"id": "2", "title": "Procedure for Adding New Modules", "authors": "Cannon, Faassen", "discussions_to": null, "status": "Active", "type": "Process", "topic": "", "created": "07-Jul-2001", "python_version": null, "post_history": "07-Jul-2001, 09-Mar-2002", "resolution": null, "requires": null, "replaces": null, "superseded_by": null, "url": "https://peps.python.org/pep-0002/", "abstract": "\nIntroduction\nThe Python Standard Library contributes significantly to Python's\nsuccess. The language comes with \"batteries included\", so it is easy\nfor people to become produ |
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 typing | |
from functools import lru_cache | |
T = typing.TypeVar("T") | |
PredicateFunction = typing.Callable[[T], bool] | |
SourceIterable = typing.Iterable[T] | |
ObjectList = typing.List[T] | |
def splitby( |
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
<html> | |
<head> | |
<title>Plusminus Dice Roller</title> | |
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> | |
<script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
<py-env> | |
- plusminus | |
</py-env> | |
</head> |
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
<html> | |
<head> | |
<script defer src="https://pyscript.net/alpha/pyscript.min.js"></script> | |
<py-env> | |
- littletable | |
</py-env> | |
</head> | |
<body> | |
<h2>Iris data</h2> |
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
<html> | |
<head> | |
<script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
</head> | |
<body> | |
<table cellpadding=30 border=2> | |
<tr> | |
<td> |
NewerOlder