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
f'{(hw:="++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.")}{(bf:=lambda prgm:print(((pc:=0),(ti:=0),(t:=[0]*30000),(rs:=[]),(o:=""),(*(((char:=prgm[pc]),(((ti:=ti+1),(pc:=pc+1))if char==">"else(((ti:=ti-1),(pc:=pc+1))if char=="<"else(((t.__setitem__(ti,(t[ti]+1)&0xFF)),(pc:=pc+1))if char=="+"else(((t.__setitem__(ti,(t[ti]-1)&0xFF)),(pc:=pc+1))if char=="-"else(((o:=o+chr(t[ti])),(pc:=pc+1))if char=="."else(((t.__setitem__(ti,ord(input())%0xFF)),(pc:=pc+1))if char==","else(((rs.append(pc),(pc:=pc+1))if t[ti]!=0 else((bc:=1),(*(((pc:=pc+1),((bc:=bc+1)if prgm[pc]=="["else(bc:=bc-1)if prgm[pc]=="]"else...),(pc:=pc+1))for _ in iter(lambda:bool(bc),False)),)))if char=="["else((pc:=rs.pop())if char=="]"else...)))))))))for _ in iter(lambda:pc<len(prgm),False)),))[-1][-1][-1][0]))}{(bf(hw))}' |
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 __future__ import annotations | |
from dataclasses import dataclass, field | |
from typing import Generic, Literal, overload, TypeGuard, TypeVar | |
T = TypeVar("T") | |
HasPopd = TypeVar("HasPopd", bound=bool) | |
@dataclass |
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
fib=(m:=globals(),(i:=lambda md:m.__setitem__(md,__import__(md)))("builtins"),i("sys"),J:=(U:="_","SIG")[1],j:=lambda *hx:U[True:].join(map(chr,hx)),p:=lambda v:v in {False,True},z:=builtins.__dict__[j(0x6C,0x65,0x6E)](()),t:=(s:=(m:=sys.modules)[U+j(115,105,103,110,97,108)],c:=m[U+j(99,111,100,101,99,115)],g:=m[j(98,117,105,108,116,105,110,115)].__dict__[j(105,110,116)],)[z].__dict__[J+g.__name__.upper()],_a:=lambda k:k.startswith(j(0o165,0o164,0o146)),tt:=list(filter(_a,c.__dict__.keys()))[(r:=~z)][t**t:t*(h:=r*(r+(z**z^r)))],ns:=t**getattr(s,j(95,95,100,105,99,116,95,95))[J+j(65,66,82,84)]+eval(tt),a:="".join(map(lambda n:chr(n+ns),x:=(eval("\x2A".join(tt)),h**t,t))),m.__setitem__(a,lambda n:n if p(n) else (y:=m[a])(n-t)+y(n+r)),l:=m[a],lambda n:print(l(n)))[-1] | |
for i in range(10): | |
fib(i) |
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 waffle_debug import debug | |
debug("The answer is {x}!") @ 6 # debug at line 6 | |
x = int(input("3 + 3 = ")) | |
x = 6 |
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
class hackint(int): | |
def __neg__(self): | |
for key, value in globals().items(): | |
if self is value: | |
globals()[key] = type(self)(self - 1) | |
return self | |
x = hackint(5) |
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
""" | |
PoC of an equivalent Python implementation of the third solution borrowed from the following video: | |
<https://www.youtube.com/watch?v=_ccDqRTx-JU> | |
Important note: Python static type checkers are independent from the interpreter, and type checking failing | |
does not prevent from running code. Considering that, the following code does NOT perform runtime checks for | |
safety. `add_password()` is still technically accessible, even through a `PasswordManager` object in a locked | |
state (i.e. `PasswordManager[Literal[True]]`). | |
The program also requires the following dependencies: |
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
# requires: >= 3.10 | |
from __future__ import annotations | |
from collections.abc import Callable | |
import functools | |
import inspect | |
from types import TracebackType | |
from typing import Concatenate, ParamSpec, TypeVar | |
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 collections.abc import Callable, Iterable, Iterator | |
from typing import Generic, Never, Self, TypeVar, overload | |
T = TypeVar("T") | |
class PrivacyError(TypeError): | |
@classmethod | |
def from_private_constructor(cls, type: type, /, *public_constructors: str) -> Self: | |
""" |
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 __future__ import annotations | |
from collections.abc import Callable, Iterable | |
import sys | |
from typing import ( | |
Any, | |
Generic, | |
Literal, | |
LiteralString, | |
SupportsIndex, |
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
#!/usr/bin/env python3 | |
import pycanvas | |
# We need this global constant to get the mouse position | |
WINDOW = pycanvas.get_window() | |
@pycanvas.init | |
async def init(canvas: pycanvas.Canvas): |
OlderNewer