This file contains hidden or 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> | |
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> | |
<script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
<py-env> | |
- pyparsing==3.0.9 | |
- railroad-diagrams | |
- jinja2 | |
</py-env> | |
<py-script> |
This file contains hidden or 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 rich.progress | |
import rich.spinner | |
import time | |
import random | |
class RandomChars(rich.progress.ProgressColumn): | |
"""Simulation of computer 'thinking' by displaying random characters | |
Args: | |
chars (str): characters from which to choose for display. Defaults to 0-9A-F. |
This file contains hidden or 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
def 𝚑𝓮𝖑𝒍𝑜(): | |
try: | |
𝔥e𝗅𝕝𝚘︴ = "Hello" | |
𝕨𝔬r𝓵ᵈ﹎ = "World" | |
ᵖ𝖗𝐢𝘯𝓽(f"{𝗵e𝓵𝔩º_}, {𝖜ₒ𝒓lⅆ︴}!") | |
except 𝓣𝕪ᵖe𝖤𝗿ᵣ𝖔𝚛 as ⅇ𝗑c: | |
𝒑rℹₙₜ("failed: {}".𝕗𝗼ʳᵐªt(ᵉ𝐱𝓬)) | |
# snippet from unittest/util.py |
This file contains hidden or 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
""" | |
bmp.py - module for constructing simple BMP graphics files | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: |
This file contains hidden or 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
# | |
# THE PROBLEM | |
# | |
# create a generator and list out its items | |
a = (n**2 for n in range(10)) | |
print(list(a)) | |
# listing it out again creates an empty list because the generator has been consumed; | |
# generators in this state will continue to raise StopIteration, but caller will take |
This file contains hidden or 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
# | |
# rcu.py | |
# | |
# Paul McGuire - November, 2020 | |
# | |
from contextlib import contextmanager | |
import copy | |
import threading | |
This file contains hidden or 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
# | |
# py_rac.py | |
# | |
# Copyright 2020, Paul McGuire | |
# | |
names = ("Voltaire|Samuel Johnson|Valery|Dante|" | |
"Nietzsche|Kant|Lao Tzu|Macchiavelli|Einstein|" | |
"Russell|Leonardo|Plato|Aristotle|Socrates|Diderot|" | |
"Descartes|Thomas Aquinas|Hawking|Emerson|Faulkner|" |
This file contains hidden or 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
# | |
# auto_namedtuple.py | |
# | |
# I like my martinis and my Python DRY | |
# | |
# Copyright 2020, Paul McGuire | |
# | |
import traceback | |
from collections import namedtuple |
This file contains hidden or 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 time, sys, base64 | |
for i, v in enumerate((getattr, time, sys, "sleep", | |
"decode", "bytes", "stdout", | |
"write", "flush", 1.0, 6, | |
base64, "upper", 1000.0, "'", | |
print, 0), start=3): | |
vars()['_'*i] = v | |
_ = ( | |
b'RGFpc3kgRGFpc3kgZ2l2ZSBtZSB5b3VyIGFuc3dlciBk' | |
b'bwpJJ20gaGFsZiBjcmF6eSBhbGwgZm9y\nIHRoZSBsb3' |
This file contains hidden or 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
# rk.py | |
# | |
# Copyright 2020, Paul McGuire | |
# | |
from typing import Callable, Sequence | |
from array import array | |
class RKIntegrator: | |
""" |