#esoteric-python

1 messages · Page 25 of 1

night quarryBOT
#

@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 0
002 | [2]
rugged sparrow
#

!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)```

night quarryBOT
#

@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 0
002 | [2]
vague cairn
#

... 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...

finite blaze
#

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.

sick hound
night quarryBOT
#

@sick hound :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 0
002 | [2]
quartz wave
#

!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

night quarryBOT
#

@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
quartz wave
#

!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

night quarryBOT
#

@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
quartz wave
#

oof

fleet bridge
#

!ti

class X: ...
night quarryBOT
#

@fleet bridge :warning: Your 3.11 eval job timed out or ran out of memory.

[No output]
fleet bridge
#

What

#

!ti

from gc import collect
collect()
class X: ...
night quarryBOT
#

@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
low lynx
#

fishhook is pretty cool too

#

i should learn it one day

rugged sparrow
sick hound
#

the repo says 100% Python, so what?

rugged sparrow
#

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.

low lynx
low lynx
rugged sparrow
#

You can wrap hooks around other hooks

#

And orig will dispatch to the next level hook

low lynx
#

that's neat

stable brook
#

!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()))]

night quarryBOT
#

@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
stable brook
#

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()))

night quarryBOT
#

@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
stable brook
#
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())))```
night quarryBOT
#

@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
last locust
low lynx
#

just put

inputs = iter([1, 2, 3])
input = lambda _: next(inputs)

before it

#

with whatever inputs you want

dry mirage
# low lynx <:pithink:652247559909277706>

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)
night quarryBOT
#

@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.

in <class '__main__.Foo'> __new__: (1, 2)
dry mirage
#

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

fleet bridge
#

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.

unique heath
#
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()```
night quarryBOT
#

@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)
unique heath
#

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()```
night quarryBOT
#

@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 "=="?
unique heath
#

!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()```
night quarryBOT
#

@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 '('
unique heath
#

!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()```
night quarryBOT
#

@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
unique heath
#

where

fleet bridge
#

Please test your code before sending it there

unique heath
#

!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()
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world!
unique heath
#

LETS GOOO

azure basalt
#

what is this profane hellscape

azure basalt
versed eagle
#

i dont think that has anything to do with cpp

unique heath
azure basalt
#

do it

dry mirage
sick hound
#

The GIL is released during file I/O operations because the GIL could bottleneck them.

#

Same applies to the standard streams

proper vault
#

yes, during this time, however, no python code is being executed on that thread

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__(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()
night quarryBOT
#

@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
unique heath
#

!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()

night quarryBOT
#

@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

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__()))))(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()```
night quarryBOT
#

@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

unique heath
#

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!"))}))```
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

('µ', (<class 'property'>,), {'Q': <function <lambda> at 0x7f306b6c0680>})
unique heath
#

!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__())))))```
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

<class 'staticmethod'>
unique heath
#

wha-

fleet bridge
#

Please go to #bot-commands @unique heath

unique heath
# azure basalt do it

!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
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world!
unique heath
#

!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
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world!
azure basalt
unique heath
unique heath
# azure basalt does this happen to create anything negative to the computer or is it the worst ...

!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())```
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello world!
unique heath
#

!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())```
night quarryBOT
#

@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

unique heath
#

!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())```
night quarryBOT
#

@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

unique heath
#

!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())```
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello world!
arctic skiff
long fulcrum
#

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{|}~

long fulcrum
#

that doesnt save chars

#

id need another print for that

#

saved 5 by changing the .ljust() to use {j:>41}

long fulcrum
#

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()```
fleet bridge
#

why memoryview(bytearray(a,"utf"))?
isnt a.encode() doing the same?

long fulcrum
#

a.encode("hex") gives LookupError: unknown encoding: hex

fleet bridge
#

do a.encode().hex(" ", -2)

long fulcrum
#

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

fleet bridge
#

it gives the same result to me

#

what strings do you have in sys.argv?

long fulcrum
#

``` !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~

fleet bridge
#

identical

long fulcrum
#

oh yeah must have just been the way I tested it

#

thats 201

rugged sparrow
# long fulcrum thats 201
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

long fulcrum
#

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

rugged sparrow
night quarryBOT
#

@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{|}~
rugged sparrow
#

ended up flipping the logic, splitting the input into 16 character chunks and then converting to hex

long fulcrum
#

holy shit

#

thats a lot smarter

#

why did I even convert to hex and back

rugged sparrow
#

yea I was doing the math in my head and realized it would be better to just invert the steps

quartz wave
#

!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()

night quarryBOT
#

@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{|}~
quartz wave
#

yep

finite blaze
rugged sparrow
#

It expands the 2 character string into 2 arguments passed into replace

quartz wave
unique heath
versed eagle
#

it creates a type with a method Q that prints stuff, then instantiates it and calls the method

unique heath
#

___ 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

versed eagle
#

the other stuff is basically just fluff around this: type("",(),{"Q":(lambda: print("hello world"))})().Q()

#

that's the core of it

unique heath
#

!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__()))))))```
night quarryBOT
#

@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

unique heath
#

zen of python 100000

#

easy to read code

tame cape
unique heath
versed eagle
#

they inherit from object by default

#

and since the name isn't ever used, it's not relevant

versed eagle
#

ye

#

exactly

unique heath
#
(___:=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)
sick hound
#

guys ive got a challenge, shortest code that prints the Fibonacci sequence

low lynx
#

because this is one of the challenges on code golf

long fulcrum
#

it's just a hexdump

finite blaze
#

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?

long fulcrum
#

is each number separated by a \n?

finite blaze
#
1010
0101
0101
0101
#

thats the file

long fulcrum
#

and you want the result to be [[1010],[0101]...]?

finite blaze
#

[[1,0,1,0],[0,1,0,1]...]

long fulcrum
#

ah ok

wheat river
finite blaze
#

well, in this example it is of len 4

#

but i want to make it work for n long numbers

wheat river
#

then probably

[[*l][:-(l[-1]=='\n')or None]for l in f]
finite blaze
#

i guess the easiest solution would be just editing the file by hand

#

and just pressing enter at the end of file xD

wheat river
#

yea, you can do this ig

[[*l[:-1]]for l in open('...')+'\n']
finite blaze
#

you can index by None?

#

thats weird

wheat river
finite blaze
#

open('...')+'\n' another cool trick that i need to remember

#

thanks

wheat river
#

actually that won't work

#

lmao

#

its not a string

finite blaze
#

i guess it should work

#

but its long, no?

wheat river
#

its like 3 chars longer than the original solution

finite blaze
#

what if i would want to parse the into ints?

#

cuz rn they are characters

wheat river
#

*map(int,l.strip())

quartz wave
#

what

#

i got confused for once

#

the channel was just filled with yellow

wheat river
#

yea lmao

low lynx
#

[[*map(int,l)]for l in open(0).read().split('\n')]

finite blaze
#

[[*map(int,l.strip())]for l in open("image")]

#

that works

low lynx
#

wait

sick hound
vapid finch
sick hound
#

@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?

sick hound
#

everything is possible :))

sick hound
vast wave
#

anything is a valid identifier in bytecode

quartz wave
vapid finch
quartz wave
vapid finch
#

Ah, okay, I see what you mean. 👍

long fulcrum
#

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("|")))

night quarryBOT
#

@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.
night quarryBOT
#

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.
long fulcrum
#

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

earnest wing
#

!eval py print(repr("Sh by are,.\nSo if onnore."))

night quarryBOT
#

@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.'
long fulcrum
#

but how does that work with the translate

earnest wing
#

\x01 becomes the [1]st value in the translate list

long fulcrum
#

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("|"))```
night quarryBOT
#

@long fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

['eeatrAtee.rIfeeeaet,rWhereesethetee?']
long fulcrum
#

!eval

print(repr(" a\nA .\nIf  a ,\nWhere's the ?"))```
night quarryBOT
#

@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?"
long fulcrum
#

it looks right to me

long fulcrum
#

nvm im an idiot

unique heath
#
(___:=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())```
night quarryBOT
#

@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

unique heath
#

fu-

fleet bridge
sick hound
#

!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())```
night quarryBOT
#

@sick hound :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello world!
low lynx
#

anyone know if it is possible to do async lambdas?

quartz wave
#

!e ```py
(lambda x: await x)

night quarryBOT
#

@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
quartz wave
#

oof

gleaming linden
#

!e ```py
(async lambda x: await x)

night quarryBOT
#

@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
wheat river
#
 lambda x: (await x for _ in '_').__anext__()
fathom forum
#

!e

night quarryBOT
#
Missing required argument

code

#
Command Help

!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!

fathom forum
#

!e print("hello")

night quarryBOT
#

@fathom forum :white_check_mark: Your 3.11 eval job has completed with return code 0.

hello
fathom forum
#

!e
while True:
print("hello")

night quarryBOT
#

@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

quartz wave
fathom forum
#

Oooh sorry got too distracted

quartz wave
#

@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

radiant anchor
#

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__)
night quarryBOT
#

@radiant anchor :white_check_mark: Your 3.11 eval job has completed with return code 0.

{'foo': 'bar', 'blah': 'abc'}
fleet bridge
night quarryBOT
#

@fleet bridge :white_check_mark: Your 3.11 eval job has completed with return code 0.

{'foo': 'bar', 'blah': 'abc'}
radiant anchor
#

I want my colons tho :(

fleet bridge
#
class json:
  foo: 'bar'
  blah: 'abc'
print(json.__annotations__)
# or with `from __future__ import annotations`:
class json:
  foo: bar
  blah: abc
print(json.__annotations__)
radiant anchor
#

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

fleet bridge
radiant anchor
#

heh nice

#

I approve

versed eagle
#

thanks for letting me know! I'll check it out once i get home

rugged sparrow
night quarryBOT
#

@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.

{'foo': 'bar', 'blah': 'abc'}
fleet bridge
#

👍

gritty smelt
#

!e print("hellow world")

night quarryBOT
#

@gritty smelt :white_check_mark: Your 3.11 eval job has completed with return code 0.

hellow world
fresh helm
#

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
fresh helm
quartz wave
#

reversing that will produce ['bob!', 'hello']

fresh helm
#

oof

#

mb

fresh helm
fleet bridge
#

list(reversed(' '.join(a).split())) looks like nonsense to me

versed eagle
#

that's just a[::-1] right?

sick hound
#

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)
versed eagle
#

no

#

reverse is pointlessly long

#

and it doesn't need to be a triple string

fresh helm
#

I think i have a working solution but i first repcae with index see if it's a digit then i swap

versed eagle
#

that's what i see immediately

#

but there's more also

fresh helm
#

+ill share progress 🙏

fresh helm
fresh helm
versed eagle
#

you mean \'?

fresh helm
#

yes

versed eagle
#

wdym it wouldn't let you

vague cairn
#

try '\' ?

#

'\\'

fresh helm
# versed eagle but there's more also

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 🙏

low lynx
#

@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

rugged sparrow
#

you need to call pythonapi.PyTypeModified anytime you directly modify a class dict to reload the classes cache

dry mirage
#

like most operator methods

low lynx
rugged sparrow
dry mirage
#

!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)
night quarryBOT
#

@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.

1024
rugged sparrow
#

ctypes.pythonapi

low lynx
#

ah thx

rugged sparrow
#

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())```

low lynx
#

!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)
rugged sparrow
#

looks like run in 3.10 might be broken

#

from ctypes import pythonapi

#

PyType_Modified

night quarryBOT
#

@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
rugged sparrow
#

and you will need to set .argtypes =[py_object]

low lynx
dry mirage
rugged sparrow
rugged sparrow
low lynx
#

ah

dry mirage
# low lynx wdym by this

the pythonapi c functions aren't typed, so they assume to have arguments and return values of c_int

low lynx
#

!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)
night quarryBOT
#

@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
rugged sparrow
night quarryBOT
#

@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
dry mirage
rugged sparrow
#

@dry mirage you wouldn't happen to know which allocator PyUnicode Writers use would you?

low lynx
#

!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)
rugged sparrow
#

I am writing a bug proof of concept that requires that i alloc a string directly where a list used to be

night quarryBOT
#

@low lynx :white_check_mark: Your 3.11 eval job has completed with return code 0.

1024
low lynx
#

heh

#

wasn't that meant to clear the cache

dry mirage
#

I think it calls PyObject_GC_NewVar

#

so PyMem_Malloc

rugged sparrow
#

cache yes, but it does not touch slot members

low lynx
#

you know what

#

I'll just make fishhook a dependency

rugged sparrow
#

i also occasionally get the string before it is narrowed so its all wide chars, which doesnt work for my impl

dry mirage
#

isn't wstr gone in 3.11?

rugged sparrow
#

not internally

dry mirage
#

oh right its removed in 3.12

rugged sparrow
#

.format starts with wide chars and then narrows

low lynx
#

is there an easy way in fishhook to like revert an entire class back to the original?

rugged sparrow
#

an entire class at once?

low lynx
#

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

rugged sparrow
#

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)

dry mirage
# low lynx and then I revert it back to int

!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())
night quarryBOT
#

@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
dry mirage
#

with no args it restores everything

rugged sparrow
dry mirage
#

hm?

rugged sparrow
#

!e print(5 .x())

night quarryBOT
#

@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'
dry mirage
#

hm...

rugged sparrow
# dry mirage hm...

!e TypeError: 'object' object is not callable can only be cause (normally) by py object()()

night quarryBOT
#

@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
dry mirage
#

!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)
night quarryBOT
#

@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'
dry mirage
#

yeah something is not working correctly with the implicit no arg version

rugged sparrow
#

!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))```

night quarryBOT
#

@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 139812092623872
002 | 139812092170112
rugged sparrow
#

hmm so its a new object

rugged sparrow
dry mirage
#

the no arg path didn't handle that apparently 😔

unique heath
#

hello esopypeople

#

bored

formal latch
#

a

unique heath
#

!e py print(__builtins__.__dir__())

#

woops

night quarryBOT
#

@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

formal latch
#

i played around with dunders like a year ago i don't remember jack shit

#

lmao

unique heath
#

lmao

formal latch
#

im opening pycharm and my fans are blasting wtf

#

(cringe)

unique heath
#

quick warning: snekbox (probably) uses 3.11.0

formal latch
#

lmao

unique heath
#

!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))
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

B
unique heath
#

!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))))```
night quarryBOT
#

@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

unique heath
#

@formal latch beat that lmfao

formal latch
#

well i spot numbers sooo

#

(cringe)

unique heath
#

meh im too lazy

meager zinc
#

not esoteric enough

#

you're missing 10000000 .__call__s

unique heath
formal latch
#

!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))```
night quarryBOT
#

@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

formal latch
#

wym

unique heath
#

wiat what

formal latch
#

(cringe)

unique heath
#

lmfao

#

l

formal latch
#

no nitro moment

unique heath
#

!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__(____________))))```
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

int(14)
unique heath
#

pog

formal latch
#

cringe using walrus operators

unique heath
#

!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__(_______________)))```
night quarryBOT
#

@unique heath :warning: Your 3.11 eval job has completed with return code 0.

[No output]
unique heath
#

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__(_______________))))```
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

eval(int(14))
unique heath
#

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__(_______)))```
night quarryBOT
#

@unique heath :warning: Your 3.11 eval job has completed with return code 0.

[No output]
unique heath
#

!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__(_______))))```
night quarryBOT
#

@unique heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

__import__('Bat')
unique heath
#

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__(_______))))```
night quarryBOT
#

@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

formal latch
unique heath
formal latch
#

🤷‍♂️

dry mirage
cunning rose
#

!e

night quarryBOT
#
Missing required argument

code

quartz wave
dusty zodiac
#
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)
tough willow
#
from math import*
n=int(input())
print(factorial(n),"\n",n*-~n//2)
quartz wave
#

!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.")

night quarryBOT
#

@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 49
002 | You're in simulated JavaScript.
unique heath
#

esopy

sick hound
#

TIL about static methods

finite blaze
#

TIL about static methods

rugged owl
#

TIL about static methods

tough willow
#

TIL about static methods

rugged sparrow
#

@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)

night quarryBOT
#

@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 49
002 | 73
dry mirage
#

!e

from einspect import view

print(view('a'))
print(view('\xff'))
night quarryBOT
#

@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>)
dry mirage
#

all 3 are different sized structs, independent from the Unicode kind

rugged sparrow
dry mirage
rugged sparrow
#

the allocation was actually the post-exploit process

rugged sparrow
#

so i could alloc data there

#

I am building a CTF challenge from the bug, ill send you the link when its done

dry mirage
#

hm... did it involve the freelist thing?

rugged sparrow
#

which freelist thing

rugged sparrow
#

because kinda?

#

dont want to spoil the challenge tho

dry mirage
#

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)
night quarryBOT
#

@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
dry mirage
#

I don't know why though, can't subclasses just use PyASCIIObject or PyCompactUnicodeObject as normal?

rugged sparrow
#

there isnt a comment somewhere explaining it?

quartz wave
rugged sparrow
#

@dry mirage could probably answer that better, I havent looked at the internals of unicode specifically

open gorge
#
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]

newlist = [x for x in fruits if "a" in x]

abvert your eyes

rugged owl
open gorge
rugged sparrow
dusty zodiac
#
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"

fleet bridge
gleaming linden
dusty zodiac
gleaming linden
#

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?

gleaming linden
#

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)

dusty zodiac
#

Mathematically speaking that would be accurate considering 2 * 2 and 2 + 2 would both output 4

gleaming linden
#

but in the original one it only prints +

dusty zodiac
#

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.

gleaming linden
#

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)
low lynx
blazing heron
#

input_str = input()
replaced_str = input_str.replace('=', '!=')

for operator in ['+', '/', '*', '-']:
result = eval(replaced_str.replace('?', operator))
if not result:
print(operator)

dusty zodiac
#

That's pretty good Golfing.

#

78 characters

low lynx
#
r=str.replace
s=r(input(),'=','-')
for x in'+/*-':eval(r(s,'?',x))or print(x)
lunar marsh
low lynx
#

nice

gleaming linden
#
a,_,b,_,c=input().split()
for x in'+/*-':eval(a+x+b+'-'+c)or print(x)
``` 69 (nice)
low lynx
#

leave it at 69

sick hound
#

TIL about static methods

tough willow
#

TIL about static methods

dusty zodiac
sick hound
#

nvm

sick hound
quartz wave
sick hound
#

where can i find this

quartz wave
sick hound
#

i understand nothing from your code 😦

unique heath
sick hound
sick hound
#

but you want to obfuscate

#

ok wait

quartz wave
sick hound
#

(_:=__name__.__len__().__class__()).__xor__(_).__ne__(_.__xor__(_))

quartz wave
#

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)

night quarryBOT
#

@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 2
002 | aa
quartz wave
#

that's the latest version

versed eagle
arctic skiff
#

how do you apply decorators to lambda?

wheat river
#

decorator(lambda ...)

thorn girder
#

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')

night quarryBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

low lynx
#

I mean you have multi letter variable names

#

and you could assign functions to some character

sick hound
dry mirage
potent flare
#

cough cough ctypes cough cough

rugged sparrow
#

An interesting obfuscation strategy would be code that modifies its own code object as it runs

#

Like swapping out constants and names

quartz wave
sick hound
#

👍

sick hound
glass drumBOT
#
Please don't do that.

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'.

low lynx
#

!e

from einspect import view, impl
@impl(int)
def __add__(self, other):
    return 2
print(1+1)
night quarryBOT
#

@low lynx :white_check_mark: Your 3.11 eval job has completed with return code 0.

2
low lynx
#

huh

quartz wave
#

what

low lynx
#

@dry mirage when I try to do that in python console it just says "getting frame variables from python runtime" and freezes

#

in pycharm

quartz wave
#

it's working fine in command prompt python

low lynx
#

yeah runs fine in a normal file for me too

#

just python console

quartz wave
low lynx
#

probably a pycharm thing

dry mirage
low lynx
low lynx
dry mirage
#

oh you mean attributes?

low lynx
#

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

dry mirage
#

!e

from einspect import view

view(int)["foo"] = "static thing"

print(1 .foo)
night quarryBOT
#

@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.

static thing
low lynx
#

oh neat

quartz wave
dry mirage
#

TypeView is essentially a dict you can set/get/del on

#

!e

from einspect import view

del view(int)["real"]

print(2 .real)
night quarryBOT
#

@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'
arctic skiff
night quarryBOT
#

@arctic skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.

its fake
night quarryBOT
#
Missing required argument

code

#

Hey @limber current!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

limber current
#

!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()

night quarryBOT
#

@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
limber current
#

!e
print("Hello world")

night quarryBOT
#

@limber current :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello world
limber current
#

!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()

night quarryBOT
#

@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
limber current
#

!e

night quarryBOT
#
Missing required argument

code

#
Command Help

!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!

limber current
#

!e
from tkinter import *

root = Tk()
root.title("Digital Clock")
root.resizable(False, False)

root.mainloop()

tough willow
#

@limber current

#

Tkinter doesnt work in the bot

limber current
#

ohh

grave rover
#

I guess this means it's time to update bytepatches for 3.11 :)

dry mirage
#

you might as well plan to target 3.12 now, beta for that will come soon

sick hound
#

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

rugged owl
#

!pypi bytepatches

night quarryBOT
grave rover
#

oh yeah I meant pyasm whoops

#

old project moment

quartz wave
#

well i mean there's only a few changes to bytecode

quartz wave
grave rover
#

why did the JIFOP and JITOP get removed NOOO

quartz wave
#

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

quartz wave
#

faster-cpython/ideas#567

glass drumBOT
quartz wave
versed eagle
#

huh

#

mark has really been busy hasnt he

quartz wave
cloud fossil
# quartz wave

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)?

cloud fossil
quartz wave
quartz wave
calm loom
#

!e

from einspect import view, impl
@impl(int)
def __add__(self, other):
    return 2
print(23+1)
#

👹

night quarryBOT
#

@calm loom :white_check_mark: Your 3.11 eval job has completed with return code 0.

24
calm loom
#

😕

low lynx
#

!e

from einspect import impl
@impl(int)
def __add__(self, other):
    return 2
print(int('23')+1)
night quarryBOT
#

@low lynx :white_check_mark: Your 3.11 eval job has completed with return code 0.

2
calm loom
#

ah

#

neat

fleet bridge
#

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.

proper vault
#

Ye, I would expect this to be branch prediction. It is measurable in other situations as well.

fleet bridge
#

how branch predictor can predict that? python VM is executing the same asm instructions before every opcode

proper vault
#

There is still an asm-level jump there in the jump if false, which could be doing it

fleet bridge
#

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

proper vault
#

The Py_IsFalse check will be an asm level branch which can get predicted afaik.

fleet bridge
#

hmm

dusty zodiac
#
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.

finite blaze
robust plank
#

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 ?
pure dew
#

this is a terrible way to do it, but dynamic imports are somewhat common, yes

robust plank
#

seems like a bad idea

quartz wave
robust plank
#

i haven't tested it
look like it should

quartz wave
#

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)

night quarryBOT
#

@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)>
robust plank
#

should i send your code to my friend or should i just tell him to stop?

potent comet
#

A much better approach would be to just call importlib.import_module.

arctic elm
#

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)

robust plank
#

what do you mean exactly with . is banned?

arctic elm
robust plank
#

my approach would probably be to make a module in which i add all the methods i need as functions

arctic elm
#

how would that work? pithink

rugged sparrow
#

assuming this is a remote server you are connected to

arctic elm
#

breakpoint is not available

rugged sparrow
#

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

arctic elm
#

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

arctic elm
#

(also it's called cursed ctf for a reason)

rugged sparrow
#

oh sweet that reminded me about that

#

i was planning on doing that one

arctic elm
#

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

rugged sparrow
#

ill look at it once i get registered

arctic elm
#

should be fine

rugged sparrow
arctic elm
#

oh, that one is cute

#

I can give a not too huge hint ||the task description isn't really truthful||

rugged sparrow
rugged sparrow
arctic elm
#

it's not ||python v1||

#

bigger hint: ||nor is it v2 or v3||

rugged sparrow
#

oh god its like ||v0||

arctic elm
#

😄

rugged sparrow
quartz wave
arctic elm
quartz wave
arctic elm
#

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__}}, {}))
robust plank
#

pretty sure this still allow a .

quartz wave
arctic elm
#

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

quartz wave
# arctic elm eval on an empty string is fine

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

arctic elm
#

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

quartz wave
arctic elm
#

presumably the ability to get a shell

quartz wave
#

unrestricted one?

arctic elm
#

in what sense?

quartz wave
#

like what kind of shell

#

because the current eval() shell is pretty free

arctic elm
#

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

quartz wave
#

there's a lot of various stuff you can do like list comprehensions and walrus assignments but idk anything else

arctic elm
#

maybe f-strings can work some magic

quartz wave
#

oh

#

great idea

#

but . isn't allowed

#

what is it gonna be used for

arctic elm
#

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

quartz wave
arctic elm
#

but even then, how would I exec that string?

quartz wave
#

idk

#

i can just do this ```py

f"{1/3j:\x2e2f}"
0.00-0.33j

arctic elm
#

close

"{\x2esystem}".format(__import__('os'))
#

actually nvm, this wouldn't help would it?

quartz wave
arctic elm
#

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

eternal prairie
#

||exec(yourself)||

#

*laughter-here

languid hare
#

not particularly appropriate

eternal prairie
#

ah, fair- should probably

dry mirage
night quarryBOT
#

@dry mirage :warning: Your 3.11 eval job has completed with return code 0.

[No output]
dry mirage
#

hm, does -c make threading work differently pithink

arctic elm
#

that wouldn't work anyway because of the constraint on . in the task

#

(but interesting that there might be non statement ways of throwing)

rugged sparrow
#

you can using (()for()in()).throw, but that requires .

next flame
#

why are we discussing challenges in an active ctf...

pearl socket
#

!e

getattr((() for () in ()), 'throw')(ValueError)
night quarryBOT
#

@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
vast basin
low lynx
#

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

sick hound
#

!e ```py
throw

#

hmm

low lynx
frank smelt
#

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
magic wraith
mental ginkgo
#

where is meme channel

finite blaze
#

i wonder why people come here looking for help

mental ginkgo
#

i also wonder

fleet bridge
#

you can get help here but it wont be helpful for you

versed eagle
#

at least, not if you're just learning python

finite blaze
#

you see "esoteric-python" and u think "yeah, that's the perfect place to get help"

vast wave
#

!e ```py
from einspect import view
view(int)["call"] = lambda *x: print(x)

(10)()

night quarryBOT
#

@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,)
vast wave
#

huh

#

oh wait it worked

#

!e ```py
from einspect import view
view(int)["call"] = lambda a, b: a+b

print(9(60))

night quarryBOT
#

@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
vast wave
#

!e ```py
from einspect import view
view(Ellipsis)["call"] = lambda s: "lmao you thought"

print(...())

night quarryBOT
#

@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
vast wave
#

huh

quartz wave
#

!e ```py
from einspect import view
view(type(Ellipsis))["call"] = lambda s: "lmao you thought"

print(...())

night quarryBOT
#

@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
quartz wave
#

Ellipsis == ...

vast wave
#

there we go

#

til Ellipsis has @_:_()

quartz wave
quartz wave
red vessel
#

What's wrong here

vast wave
#

also we cant see shit

red vessel
quartz wave
red vessel
#

Lists

vast wave
#

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

zenith geode
#
isSubset = lambda x, y: all(b in x for b in y) or all(b in y for b in x) 

rooThink

gleaming linden
earnest wing
#

Sets have lots of fun sugar

sick hound
#

can someone add some more nonsense to this? lol

lambda: lambda: map(lambda *, _,: _ ** _ | (_ := _ + _) / _ & _ != _ ^ _ | _ >= _^_ | _%_ == _, range(tuple(map(int, map(str, (0, 10))))[0]))```
meager zinc
#

*it returns a lambda which returns an empty map

versed eagle
#

python is actually a quite sensible language, overall

long fulcrum
#

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```
long fulcrum
#

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...

quartz wave
long fulcrum
#

invalid decimal literals

rugged sparrow
#

!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

night quarryBOT
#

@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

rugged sparrow
#

at least not yet

long fulcrum
#

oh didnt realise

#

output is wrong though

#

its just outputting a big triangle

rugged sparrow
#

ah i didn't check that

long fulcrum
#

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```
last locust
#
"█"if x in u else" "```is the same as```py
" █"[x in u]```to shorten it some more
long fulcrum
#

nice 159

quartz wave
#

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

long fulcrum
#

yeah I could not figure oout how to use a list instead of a set

arctic elm
#

quite cursed

#

replace compile and a few other things, import xml module which (I'm assuming) ends up doing a compile and exec

rugged sparrow
#

Ohh I should have known the compile trick

fleet bridge
#

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

rugged sparrow
#

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

fleet bridge
#

cool

rugged sparrow
#

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

fleet bridge
#

same with this: assert abc(('ab', 0)) == None

rugged sparrow
#

weird

rugged sparrow
fleet bridge
#

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

low lynx
#

I'm kinda confused

#

do the parsers modify inp?

#

ohh inp is getting reassigned

#

nvm I understand

rugged sparrow
#

|| ```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

fleet bridge
low lynx
#

should we check explicitly if it's None or can we just use the falsy nature

rugged sparrow
#

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

fleet bridge
rugged sparrow
#

yea that works

#

if only we had tuple comprehensions /s

#
(x for x in [...],)```
fleet bridge
#

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
)

rugged sparrow
fleet bridge
#

oof

rugged sparrow
# fleet bridge 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

rugged sparrow
# fleet bridge oof

|| ```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

quartz wave
dusty zodiac
#
x=input
for i in range(int(x())):print(bin(int(x()))[2:])
#

Just prints out value's binary

last locust
#

You can easily make that oneline with a walrus (ignoring ; since that's cheating)

dusty zodiac
last locust
#

range(int((x:=input)()))

#
for _ in range(int((i:=input)())):print(bin(int(i()))[2:])
dusty zodiac
#

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}")
low lynx
#

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}')
arctic elm
#

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()))
dusty zodiac
#

Pretty good golfing as always dang

#

both yall great golphers

arctic skiff
arctic elm
#

it's the same length and uglier

fleet bridge
#

Uglier = better

arctic elm
#

everything else equal, prettier is better 😔

low lynx
last locust
#
[print(f'{int(x):b}')for x in open(0)[1:]]```looks like the shortest without "cheats" (`exec`/`;`)
low lynx
#

golfing is not uglifying code

#

exec is perfectly valid golfing wdym

arctic skiff
# arctic elm why?

!epy print(len("""exec("print(f'{int(input()):b}');"*int(input())) """)) print(len("""i=input;exec("print(f'{int(i()):b}:);"*int(i())) """))

night quarryBOT
#

@arctic skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 49
002 | 49
arctic skiff
#

Umm

arctic elm
low lynx
#

yeah i don't think open(0) is slicable

arctic elm
#

it's not

low lynx
arctic elm
#

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

low lynx
#

would be nice if you had sliceable IO types

rugged sparrow
#

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

vapid finch
#

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.

rugged sparrow
vapid finch
#

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.

arctic elm
#

so it would be kinda weird

low lynx
#

yeah that's fair

arctic elm
#

and slicing is quite expensive if it's slicing lines

#

slicing bytes could make sense, and it could actually be efficient on regular files

arctic elm
#

I think in this case just str.strip would be neater, unless you want to be generic and accept bytes

finite blaze
#
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?

rugged owl
fleet bridge
#

!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')

night quarryBOT
#

@fleet bridge :white_check_mark: Your 3.11 eval job has completed with return code 0.

ok
fleet bridge
#

syntax highlighters are dying

#

i love how mypy is giving me only one random error inside this huge lambda mess

meager zinc
versed eagle
#
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

quartz wave
#

68 ```py
c=e=sum(t:=eval('int(input()),'2))
exec("e=c+t[e%2];"
~-c)
print(e)

versed eagle
#
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])

versed eagle
gleaming linden
#

and swap the tuple around

versed eagle
#

doesnt work

versed eagle
# gleaming linden `b%2<=a%2` -> `a%2>b%2`?
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

versed eagle
#

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])

pearl socket
#

!e

print(eval(''.join([chr(ord(_)+1)for _ in....__eq__.__class__.__name__]),{'nfuipe':type('',(),{'xsbqqfs':'Hello, world'})},{}))
night quarryBOT
#

@pearl socket :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world
restive void
#

!e

print(...)
night quarryBOT
#

@restive void :white_check_mark: Your 3.11 eval job has completed with return code 0.

Ellipsis
finite blaze
#

Thanks

#

I'll need to read about it

oblique gyro
#

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

rugged sparrow
#

!pep 701

night quarryBOT
#
**PEP 701 - Syntactic formalization of f-strings**
Status

Accepted

Python-Version

3.12

Created

15-Nov-2022

Type

Standards Track

oblique gyro
#

Wow, good to know, thanks for the info!

sick hound
oblique gyro
#

Yeah, I read through most of that document, it's cool info

#

Hype for 3.12

tough willow
#

Python 4 when

last locust
tough willow
#

Sorry