#esoteric-python

1 messages ยท Page 127 of 1

proper vault
#

but it would be pretty simple all things considered

floral meteor
#

lmao

#

you wanna bet

#

although the bot cannot import custom scripts

#

ยฏ_(ใƒ„)_/ยฏ

#

unless you just completely replaced import in which case still dead easy

rugged sparrow
#

you can just store state inside the module and use a module wide __getattr__

proper vault
#

__getattr__ does not get called every time, just the first time an attribute is accessed IIRC

#

oh nvm

#

oh, only for relative imports

#

!e

import __main__ as m
def __getattr__(name):
    print('get', name)
m.a
m.b
m.a
m.b
from __main__ import a
from __main__ import b
from __main__ import a
night quarryBOT
#

@proper vault :white_check_mark: Your eval job has completed with return code 0.

001 | get a
002 | get b
003 | get a
004 | get b
005 | get __path__
006 | get a
007 | get a
008 | get __path__
009 | get b
010 | get b
011 | get __path__
proper vault
#

yeah, doesn't quite work

earnest wing
#

I wonder

#

!e ```py
import main as m
@type.call # an expression post-3.9
class all():
def getitem(*_):
return # should error
from main import *

night quarryBOT
#

@earnest wing :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 6, in <module>
003 | TypeError: Item in __main__.__all__ must be str, not NoneType
sick hound
#

i already asked, but... does exist a program choose alone the good python --version for interpreter in my IDE in fonction of module using inside the *.py ?

#

import builtin ?

sick hound
#

does anyone here ?....hello

potent cliff
#

Sorry but that's completely unintelligible to me

#

Most IDEs will automatically choose the newest installed python on your $PATH if that's what you're asking

#

@sick hound ^

#

But I don't think that's a question pertaining to this channel either. Sounds more like an #editors-ides question

sick hound
#

i mean...if for exemple speedtest module is inside my programe and my ide is programing for running with python3.9 and this speedtest its running only with python2.7>>>>each time i need to change setting of my interpreter and if i run an other program, i need chang again...do you anderstand ?

next flame
#

@sick hound please read the channel topic ๐Ÿ™‚

gaunt ferry
#

how to drop duplicate columns after joining dataframe in pyspark dataframe

rugged sparrow
#

@gaunt ferry @sick hound this is not a help channel

sick hound
potent cliff
#

Bruh

rugged sparrow
#

(lambda: "esoteric python")()``` it literally explains what it means by esoteric
next flame
#

or just scroll up and see what others have posted lol

tiny meteor
#
#hi

def ReallyAdvancedMathCalculationThatIsReallyImportant(WhetherOrNotToReturnTheCorrectResult: bool):
    if WhetherOrNotToReturnTheCorrectResult is not False or WhetherOrNotToReturnTheCorrectResult is True:
        #Fuck you
        WhetherOrNotToReturnTheCorrectResult = True 
    if True is True and True is not False or WhetherOrNotToReturnTheCorrectResult is True:
        if 1 + 1 == 2:
            return 0.1
        else:
            #HOW
            #Fuck you
            return __import__("math".replace("math","random")).randint(10000000000, 10000000001)

asyncio =\
    __import__\
                ("\ntime".replace("\n",""))

for ForLoopVariable in [None, None, None, None]:
    if ForLoopVariable is None or None or None or None or None or None or None or None:
        asyncio.sleep(ReallyAdvancedMathCalculationThatIsReallyImportant\
            (WhetherOrNotToReturnTheCorrectResult=False))
        
print("This message must be printed or else.".replace("This message must be printed or else.", "\n"))

class ReallyStupidFuckingThing:
    def __init__(self): self = self; self._ = ["avery"
, "was", "here"
        ]

class TheStupidistFuckingThing(ReallyStupidFuckingThing):
    def __init__(self) -> None:
        super().__init__()
    def TheFinaleOfStupidFuckingThings(self, true: bool = True):
        if true is not True or true is False: true = True
        if true is not None or true is not False or true is True and true is not None:
            return self._

_ = TheStupidistFuckingThing().TheFinaleOfStupidFuckingThings(False)

print\
(" ".join(_)\
    )         ;

sys = __import__\
                                ("plat\n\n\n\n\n\n\n\n\n\n\nform".replace("\n","\n".replace("\n","")))

_________ = "this pytho\nn ver\nsion is".replace("\n","") + " ".replace(
    " ",
    ""
)
reallyImportantString = "abcde".replace(
    "a", "").replace(
        "b", "").replace("c", "").\
            replace("d", "").replace(
                
                "e",
                "");
def NoneIsNoneOrNoneIsNoneAndNoneIsNone():
    if None is None or None is not None or None is None and None is None and None is None:
        return None is not None or None is None and None is None
if NoneIsNoneOrNoneIsNoneAndNoneIsNone() or NoneIsNoneOrNoneIsNoneAndNoneIsNone() is not False:
    print(
        \
        _________,
        \
        sys.python_version(
        )
        )
#

hello does this count

rugged sparrow
#
Python 3.9.6 (default, Jun 29 2021, 06:20:32) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def ReallyAdvancedMathCalculationThatIsReallyImportant(WhetherOrNotToReturnTheCorrectResult: bool):
...     if WhetherOrNotToReturnTheCorrectResult is not False or WhetherOrNotToReturnTheCorrectResult is True:
...         #Fuck you
...         WhetherOrNotToReturnTheCorrectResult = True 
...     if True is True and True is not False or WhetherOrNotToReturnTheCorrectResult is True:
...         if 1 + 1 == 2:
...             return 0.1
...         else:
...             #HOW
...             #Fuck you
...             return __import__("math".replace("math","random")).randint(10000000000, 10000000001)
... 
>>> from fishhook import hook_cls, orig
>>> @hook_cls(int)
... class int_hook:
...     def __hash__(self):
...             return self
...     def __eq__(self, other):
...             if self is 2 and other is 2:
...                     return False
...             return orig(self, other)
... 
<stdin>:6: SyntaxWarning: "is" with a literal. Did you mean "=="?
<stdin>:6: SyntaxWarning: "is" with a literal. Did you mean "=="?
>>> 1 == 1
True
>>> 2 == 2
False
>>> ReallyAdvancedMathCalculationThatIsReallyImportant(0)
10000000001
>>> ``` @tiny meteor
tiny meteor
#

oh no

golden finch
#

surely there must be some way to override int.__add__ easily

rugged sparrow
#

you can use fishhook

golden finch
#

without fishhook

#

how does fishhook work, anyway?

floral meteor
golden finch
#

@rugged sparrow are you there?

rugged sparrow
#

Fishhook swaps pointers around

#

To hook builtin classes

#

@golden finch I can send a smaller hook implementation in an hour or 2

golden finch
#

okay

rugged sparrow
#

!paste

night quarryBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

rugged sparrow
golden finch
#

thanks!

#

wow, that's big

#

@rugged sparrow how, exactly, does this work?

tribal moon
#
ENDIAN = ['little','big'][1%memoryview(b'\1\0').cast('h')[0]]```

You can also get the byte structure by doing ```py
ENDIAN = sys.byteorder```
#

it's the same thing

rugged sparrow
#

goal was no imports @tribal moon

tribal moon
#

ah then that's a really clever way ๐Ÿ˜„

rugged sparrow
#

@golden finch it uses a bug involving closures to get rw access to python memory

#

it then toggles a flag in the class to allow attribute modification, sets the attribute, then untoggles the flag

golden finch
#

wow

#

okay

rugged sparrow
#

it also has a pure python implementation of PyTypeModified that triggers subclasses to update

tribal moon
#

You should write your own tutorial on all of this it'd be a really nice read

golden finch
#

I think I might need a rundown of each line, wow

tribal moon
#

from start to end

golden finch
#

r:=iter(range(2**63-1) - why not use iter(int,1)?

rugged sparrow
#

needs to be a range_iter object

#

part of the bug

golden finch
#

ah

#

where's the bug and how does it work?

rugged sparrow
#

im making a write up

golden finch
#

sweet, thanks

rugged sparrow
golden finch
#

thanks, will try and read

umbral osprey
#

Just watching an old PyCon talk and they mentioned an izip() that acts like zip() but without the double memory cost incurred by inserting the items into the zip() object. Is this still a feature? I can't find it in the current docs...

earnest wing
#

That's only 2.7.

#

The current zip does what the old izip did.

proper vault
#

zip now does that

earnest wing
#

For the most part, all similar builtin functions now compose iterators.

#

map, filter, reversed, ...

proper vault
#

sorted returns a list, but it does take an iterable

earnest wing
#

Sorry, I meant reversed

#

I don't think you can stream a sorting algorithm in nlogn time

proper vault
#

yeah, you can't

umbral osprey
#

All hail the iterable!

proper vault
#

I don't think you can even sort a stream

#

without just copying it all into a buffer

earnest wing
#

well, technically you ca-
yeah buffer cheats

dire galleon
#

?

woven bridge
#

lazy quicksort, no buffer

#

well, not a 'put everything in' buffer

simple crystal
#

a function's __call__ gets used when you call it right

#

???

#

me too

woven bridge
#

!e

def func():
  pass

func.__call__ = lambda: print('hi')
func()
night quarryBOT
#

@woven bridge :warning: Your eval job has completed with return code 0.

[No output]
woven bridge
#

youll have to check the source to see whats happening

simple crystal
#

ya

#

basically hoping chilaxan or someone who already knows pops in haha

woven bridge
#

its probably like how 1+1 wont care about int.__add__ and will just do some optimized addition specific to ints

#

the interpreter cheats

simple crystal
#

ah didn't know that

proper vault
#

@woven bridge tee just puts the iterable in a buffer.

simple crystal
#

the interpreter doesn't call dunder methods on integer literals?

woven bridge
simple crystal
#

!e

def c():print('c')
c()
c.__call__()
c.__call__ = print('not c')
c()
c.__call__()
night quarryBOT
#

@simple crystal :x: Your eval job has completed with return code 1.

001 | c
002 | c
003 | not c
004 | c
005 | Traceback (most recent call last):
006 |   File "<string>", line 6, in <module>
007 | TypeError: 'NoneType' object is not callable
simple crystal
#

ah I'll check it out

#

so __call__ is just a copy

woven bridge
woven bridge
#

all good

woven bridge
#

thats kinda disappointing

simple crystal
#

wait these look like what I already knew c-defined dunders are

proper vault
#

@woven bridge it depends on what order you consume it in, it is slightly optimised if you do things when it can omit a buffer, but from what I can tell the algo wouldn't do that

simple crystal
#

int.__add__ is a slot wrapper yeah

#

that's what you meant?

woven bridge
# simple crystal that's what you meant?

yeah, so like if you had two arbitrary objects x and y youd expect x+y to result in the dunder call x.__add__(y) or y.__radd__(x). but the interpreter eschews this when x and y are ints for optimization. similarly, theres probably an optimization to avoid the overhead of using a function's __call__ dunder to speed up function calls.

simple crystal
#

well it uses the equivalent int has to a .__add__*

#

but it's a c-defined type

earnest wing
#

Check slots first, then python methods?

#

Am I getting this slightly wrong

simple crystal
#

idk how calls work tho

#

but I should have checked the result of changing __call__ haha

simple crystal
woven bridge
#

admittedly this is from 2016 so things might be different now

simple crystal
#

hmmm wish I knew where this code was

woven bridge
#

ceval.c, theres a huge switch statement

#

theres some weird shit going on in the main branch with quickening that i dont really understand yet

#

so you could also switch to stable version branches on the repo and check their ceval.c instead

steel siren
#

not not is faster than bool

#

just a psa for everyone that didnt know that

woven bridge
steel siren
#

!e ```py
import timeit

def test1():
bool([])

def test2():
not not []

print(timeit.timeit(test1, number=1000000))
print(timeit.timeit(test2, number=1000000))```

night quarryBOT
#

@steel siren :white_check_mark: Your eval job has completed with return code 0.

001 | 0.35323254857212305
002 | 0.22308364789932966
simple crystal
#

and yeah main branch is way different now

#

apparently

night quarryBOT
#

Python/ceval.c lines 1999 to 2012

TARGET(BINARY_ADD): {
    PREDICTED(BINARY_ADD);
    STAT_INC(BINARY_ADD, unquickened);
    PyObject *right = POP();
    PyObject *left = TOP();
    PyObject *sum = PyNumber_Add(left, right);
    SET_TOP(sum);
    Py_DECREF(left);
    Py_DECREF(right);
    if (sum == NULL) {
        goto error;
    }
    DISPATCH();
}```
woven bridge
#

oo ok nice, so they took that micro-optimization out

#

lmao really? TIL

#

oh hold on...

#

why no preview lemon_pensive

#
        TARGET(BINARY_ADD_INT): {
            PyObject *left = SECOND();
            PyObject *right = TOP();
            DEOPT_IF(!PyLong_CheckExact(left), BINARY_ADD);
            DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_ADD);
            STAT_INC(BINARY_ADD, hit);
            record_hit_inline(next_instr, oparg);
            PyObject *sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
            SET_SECOND(sum);
            Py_DECREF(right);
            Py_DECREF(left);
            STACK_SHRINK(1);
            if (sum == NULL) {
                goto error;
            }
            DISPATCH();
#

_PyLong_Add doesnt care about slots, i dont think

#

quickening

#

some instructions are gonna have their own specializations

#

that they get swapped out for after some observation of how the code runs? at least thats what i got from reading the pep

#

!pep 659

night quarryBOT
#
**PEP 659 - Specializing Adaptive Interpreter**
Status

Draft

Created

13-Apr-2021

Type

Informational

woven bridge
#

not sure if cases like 1+1 will get compiled using BINARY_ADD_INT or still rely on quickening to specialize later

#

Quickened code has number of advantages over the normal bytecode:

It can be changed at runtime
It can use super-instructions that span lines and take multiple operands.
It does not need to handle tracing as it can fallback to the normal bytecode for that.

these arent advantages for #esoteric-python lemon_pensive (and actually not quite sold that theyre advantages in general tbh)

gonna have to change all bytecode hacks to now take quickening into account

potent comet
woven bridge
# potent comet It shouldn't really matter actually, the regular bytecodes will remain (or equiv...

thats not quite the issue im seeing. lets say you write a bytecode hack that alters the bytecode of a frame by mutating the memory of the code object directly, suddenly you have to take into account quickening having occurred and some of the code you altered no longer being ran because it gets skipped due to optimization, i.e. you swapped out a BINARY_ADD for something else but the quickener has already decided to run a specialized version of BINARY_ADD at that instruction, so your change is ignored (that is unless the quickener mutates the original code, which im assuming it doesnt since it has to be able to fall back if necessary)

#

theres also problems even if youre not modifying the code since specializations wont let you make the same assumptions about what an instruction will always do any more

rugged sparrow
rugged sparrow
#

but also when an object is called obj() it actually causes python to do this -> type(obj).__call__(obj)

earnest wing
#

!e ```py
class A:
call = lambda s: print("a")
a = A()

a()
a.call()
type(a).call(a)

a.call = lambda: print("b")

a()
a.call()
type(a).call(a)

A.call = lambda s: print("c")

a()
a.call()
type(a).call(a)

night quarryBOT
#

@earnest wing :white_check_mark: Your eval job has completed with return code 0.

001 | a
002 | a
003 | a
004 | a
005 | b
006 | a
007 | c
008 | b
009 | c
earnest wing
#

this demonstrates it pretty well I think

#

Assigning to the instance doesn't change the behavior of ()

rapid sparrow
golden finch
#

and since functions are objects

golden finch
#

!e

class foo:
  def __call__(*args):
    print(args)
bar=foo()
bar()
night quarryBOT
#

@golden finch :white_check_mark: Your eval job has completed with return code 0.

(<__main__.foo object at 0x7f71db8e2fd0>,)
golden finch
#

fascinating

#

does this apply for functions too?

#

for that matter, can type(lambda:0).__call__ be overridden

rugged sparrow
#

Technically yes

night quarryBOT
#

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

'โˆ“'
golden finch
#

oh

#

that might have a little bit to do with it

#

just a little

rich hound
#

i made something useless.

golden finch
#

well, don't keep us waiting!

rich hound
#

and unnecessarily complicated

#

!e ```py
print("hello world"[--(int(()==())**2)::].replace("_","useless var "[--(int(()==())**2*11)]))

night quarryBOT
#

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

hello world 
rich hound
#

thats better

#

dont you agree @golden finch

golden finch
#

what in the

#

impressive

rich hound
#

idk

#

how

#

how is it impressive

golden finch
#

it's using a variety of syntax features

rich hound
#

yes.

#

its basically an over engineered ```py
"hello world".replace("_", "")

#

but the first _ was removed by [--(int(()==())**2)::] \ [--1::]

#

i had old projects but i wiped them by accident

rich hound
golden finch
#

most definitely

rich hound
#

i wanna see

#

make it unreadable

golden finch
#

this

rich hound
#

o.o

#

i mean

#

just why

golden finch
#

you asked

rich hound
#

yeah

#

i did

#

but can you do it

golden finch
#

me? I'm not free rn

rich hound
#

ohok

golden finch
#

I'd start with bytecode modification, metaclasses, ctypes

rich hound
#

o.o

floral meteor
#

Yes you can

#

Have you heard of the walrus operator?

golden finch
#

globals().update too

floral meteor
#

vars(builtins).update also

#

Because builtins is just another namespace like globals and locals

woven bridge
#

youre replying to a message from july 2018... a year before 3.8 was ever released

floral meteor
#

Who?

woven bridge
#

you

floral meteor
#

Wha-

#

Howd I even get there?

woven bridge
floral meteor
#

Well that explains a lot

#

But you could still globals().update

pastel ibex
#

Lmao probably from the reply anonymousdeveloper did

night quarryBOT
#

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

Hello World!
rich hound
#

o.o

#

wtf lmao

lethal shore
#

Heelo worrld

dire galleon
#

yes.

golden finch
#

okay that is exremely impressive

floral meteor
turbid dragon
#

imagine the scenes if you deleted a (

lunar moon
#

ikr

sick hound
#

lol

harsh spear
#

!e ```py
metamaker = (lambda meta, cls: ( lambda: [ (dict_.pop(es, None) for es in dict_.get("slots", tuple())) if [None for [globals()["dict_"]] in [[dict(cls.dict)]]][0] is None else None, [None for [globals()["dict_"]["metaclass"]] in [[meta]]], [None for [globals()["dict"]["wrapped"]] in [[cls]]], meta(str(cls.name), tuple(cls.bases), dict), ][-1]))
printf = lambda format_string, *args: print(format_string,end="") if not args else print(format_string % args,end="")
main = metamaker(type("b", (type,), {"call": lambda self, : {None}}), type("", (object,), {}))()
int = metamaker(type("a", (type,), {"sub": lambda self2, : {None} if isinstance(, set) else [None for [globals()[
.split("=")[0]]] in [[import('builtins').int(_.split("=")[1])]]][0]}), type("a", (object,), {}))()
void = None
return_0 = None

int-main(void)-{
printf("Hello, World!\n"),

int-"num1=2",
int-"num2=3",

printf("%d + %d = %d\n", num1, num2, num1+num2),
return_0
}```

night quarryBOT
#

@harsh spear :white_check_mark: Your eval job has completed with return code 0.

001 | Hello, World!
002 | 2 + 3 = 5
cloud fossil
#

Reject Python
Return to C

#

But hey, why no semicolons

#

Still impressive though

next flame
#

cuz its within a set literal

cloud fossil
#

Incredible

thorny tapir
#

WHAT IN The WORLD

harsh spear
#

:)

night quarryBOT
#

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

Hello World!
harsh spear
#

lol

thorny tapir
#

add a ;

#

!e

def printf(text):
  print(text)

# c :O
printf("Hello World!");
night quarryBOT
#

@thorny tapir :white_check_mark: Your eval job has completed with return code 0.

Hello World!
night quarryBOT
#

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

001 | Hello, World!
002 | 2 + 3 = 5
knotty delta
#

you could've set end to '' in the print function you called in printf, i think that c's printf doesn't have a newline ending

golden finch
#

^

#

also, printf is a bit more advanced

#

it uses formatting

night quarryBOT
#

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

Hello World!test
simple crystal
#

!e

def printf(s, *a):
    print(end=s%a)

printf('%i %a', 3, 4)
night quarryBOT
#

@simple crystal :white_check_mark: Your eval job has completed with return code 0.

3 4
golden finch
#
printf = lambda format_string, *args: print(format_string,end="") if not args else print(format_string % args,end="")

from the above code

#

works for both

simple crystal
#

!e

def printf(s, *a):
    print(end=s%a)

printf('this works too')
night quarryBOT
#

@simple crystal :white_check_mark: Your eval job has completed with return code 0.

this works too
simple crystal
#

args is an empty tuple anyway

golden finch
#

ah right

raw ridge
#

!e
console.log("hi")

#

Eh

#

Nvm

#

Uh

#

I was just testing

shut trail
#

This isn't really that esoteric but I don't know where to put it lol,

I created a decorator that can call different functions based off the syntactic context functools.singledispatch with context

#

Ah, it doesn't work on snekbox for some reason

#
def contextdispatch(function):
    contexts = {}

    def register(context: str):
        def register_decorator(func):
            contexts[context] = func

            def running_register(*args, **kwargs):
                return func(*args, **kwargs)

            return running_register

        return register_decorator

    def run_function(*args, **kwargs):
        function_called = stack()[-1].code_context[-1].rstrip('\n')
        for context, func in contexts.items():
            if re.search(pattern=fr"{context}", string=function_called):
                return func(*args, **kwargs)
        else:
            return function(*args, **kwargs)

    run_function.register = register
    return run_function

this is the decorator

#
@contextdispatch
def testing():
  print("not used in a for loop")

@testing.register(r"for . in testing\(\)")
def for_loop():
  print("this was used in a for loop")
  return range(1, 20)

>>> for i in testing():
    ... pass

>>> "this was used in a for loop"
>>> testing()
>>> "not used in a for loop"
earnest wing
#
"""
this

?

#

or do you mean

"this is valid"""

?

#

!e ```py
peg_parser

night quarryBOT
#

@earnest wing :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     __peg_parser__
003 |     ^
004 | SyntaxError: You found it!
earnest wing
#

Repls should use pretty much the same parser as any other python runtime

#

No need to make weird special cases for just repl when a normal program can have it

#

And do they?

snow beacon
#
>>> """
...
  File "<stdin>", line 1
    """
      ^
SyntaxError: EOF while scanning triple-quoted string literal
#

I'm not sure if this counts.

earnest wing
#

if you pipe, sure

#

otherwise it works as described

formal sandal
#
# getters.py
def __getattr__(name):
    def _getter(self):
        return getattr(self, f"_{name}")
    _getter.__name__ = name
    return property(_getter)


# main.py
class Foo:
    from getters import bar, baz

    def __init__(self, bar, baz):
        self._bar = bar
        self._baz = baz

x = Foo(1, 5):
print(x.bar)
print(x.baz)
``` ```
1
5
#
# destruct.py
_obj = None

def pick(obj):
    global _obj
    _obj = obj

def __getattr__(name):
    return getattr(_obj, name)
``` ```py
# main.py

import destruct
from collections import namedtuple

Point = namedtuple("Point", ["x", "y"])

def f(point):
    destruct.pick(point)
    from destruct import x, y
    print(f"{x=}, {y=}")

f(Point(1, 5))
1
5
lone gust
#

can a lambda not raise an exception?

astral rover
#

it can you just have to do generator stuff

#

raise_ = lambda:(_ for _ in ()).throw(Exception())

lone gust
#

wow

sonic river
#

How i can install git

#

Windows

thorny tapir
#

git install git /j

snow beacon
snow beacon
golden finch
#

generators have a .throw method

#

cursed

floral meteor
#

!e after all you've seen in this server .throw is cursed?

class Yeet(Exception):...
(()for()in()).throw(Yeet, 'yeet!')
night quarryBOT
#

@floral meteor :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 2, in <genexpr>
004 | __main__.Yeet: yeet!
golden finch
golden finch
#

mhm

#

but if the second tuple() isn't a variable, how does that work?

#

mhm

#

right

golden finch
#

still don't get why

#

mhm

potent comet
#

[] = ... unpacks into nothing, which is basically an assertion that the iterator is empty.

rugged sparrow
#

(()for()in() is a generator that yields an empty tuple for every time nothing is unpacked from an empty tuple. It loops zero times, and only serves the purpose of making a generator type object for the .throw method

golden finch
#

ah

#

that's cool

snow beacon
#

Another summary, in code form:```py
In [1]: for a,b,c in [(1,2,3), (4,5,6)]: print(a, b, c)
1 2 3
4 5 6

In [2]: for (a,b,c) in [(1,2,3), (4,5,6)]: print(a, b, c)
1 2 3
4 5 6

In [3]: for () in [(), ()]: print()

In [4]: for () in []: print()

In [5]: for () in (): ()

In [6]: (()for()in())
Out[6]: <generator object <genexpr> at 0x7f45856854a0>

golden finch
#

Thanks, that makes a lot more sense

#

it's also incredibly cursed

#

is there a shorter way to make a genexpr? also, why would it have .throw?

rugged sparrow
#

.throw raises the exception inside the generator

rugged sparrow
#

!e ```py
def sum_all():
total = (yield)
while (next := (yield total)) is not None:
total += next
yield total

summer = sum_all()
next(summer) # contiues to first yield
for i in range(10):
print('Running total:', summer.send(i)) # print running total
print(summer.send(None)) # end the while loop and print final total```

night quarryBOT
#

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

001 | Running total: 0
002 | Running total: 1
003 | Running total: 3
004 | Running total: 6
005 | Running total: 10
006 | Running total: 15
007 | Running total: 21
008 | Running total: 28
009 | Running total: 36
010 | Running total: 45
011 | 45
golden finch
earnest wing
#

!e (yield).throw(TypeError)

night quarryBOT
#

@earnest wing :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 | SyntaxError: 'yield' outside function
earnest wing
#

hm right that's more restricted

#

actually no I'm being silly

#

ignore that

charred pulsar
#

!e print("Hello")

golden finch
#
(lambda:(yield))()
(0for()in())

looking like it's minimal

golden finch
#

Nor did I

#

I don't know what it does but I think it's cursed

#

yield is confusing in general

floral meteor
#

!e ```py
for this in(lambda:(yield))():print(this)

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

None
rich hound
#

!e ```py
print("hello world"[--(int(()==())**2)::].replace("_",f"useless var{chr((()==()+()==()*(()==()+()==()16)))}"[--(int(()==())**211)]))

#

shiT

night quarryBOT
#

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

hello world
rich hound
#

HAHAHAHAH

#

ooh i have an idea

#

!e ```py
print("hello world"[--(int(()==())**2)::].replace("_",f"useless var{chr((()==()+()==()*(()==()+()==()16)))}"[--(int(()==())**211)])[0:].upper())

#

H.

#

h.

#

oh

#

shi

night quarryBOT
#

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

HELLO WORLD
rich hound
#

!e ```py
print("hello world"[--(int(()==())**2)::].replace("_",f"useless var{chr((()==()+()==()*(()==()+()==()16)))}"[--(int(()==())**211)])
.replace([0:],[0:].upper(),1))

#

shit

#

not good

#

wh

#

yeah true

#

what

#

oho

night quarryBOT
#

@rich hound :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     .replace([0:],[0:].upper(),1))
003 |                ^
004 | SyntaxError: invalid syntax
rich hound
#

mmmm

#

!e print(ord("w"))

night quarryBOT
#

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

104
rich hound
#

!e ```py
print("hello world"[--(int(()==())**2)::].replace("_",f"useless var{chr((()==()+()==()*(()==()+()==()16)))}"[--(int(()==())**211)])
.replace(chr(104),chr(104).upper()))

night quarryBOT
#

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

Hello world
rich hound
#

!e print(ord("w"))

night quarryBOT
#

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

119
rich hound
#

!e ```py
print("hello world"[--(int(()==())**2)::].replace("_",f"useless var{chr((()==()+()==()*(()==()+()==()16)))}"[--(int(()==())**211)])
.replace(chr(104),chr(104).upper()).replace(chr(119),chr(119).upper())+chr(33))

#

!e print(ord("!"))

night quarryBOT
#

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

33
#

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

Hello World!
rich hound
#

@iron cedar

#

come look

#

!e ```py
print("hello world"[--(int(()==())**2)::].replace("_",f"useless var{chr((()==()+()==()*(()==()+()==()16)))}"[--(int(()==())**211)])
.replace(chr(104),chr(104).upper()).replace(chr(119),chr(119).upper())+chr(33))

night quarryBOT
#

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

Hello World!
iron cedar
#

๐Ÿค”

#

overcomplicated "Hello world"

rich hound
#

yes.

#

this is worse

#

mines still good

#

yes i know

#

hmm

#

couple years

iron cedar
#

wow

rich hound
#

@sick hound is mine good?

#

ty

#

!e

print("_hello world_"[--(int(()==())**2)::].replace("_",f"useless var{chr((()==()+()==()*(()==()+()==()*16)))}"[--(int(()==())**2*11)]).replace(chr(104),chr(104).upper()).replace(chr(119),chr(119).upper())+chr(33)+"".join(chr(_)for _ in[32,70,114,111,109,32,78,111,120,46]))
night quarryBOT
#

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

Hello World! From Nox.
rich hound
#

what

#

box?

iron cedar
#

Nox

#

hm

rich hound
#

!e print(ord(''))

night quarryBOT
#

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

1
rich hound
#

why is that there

#

oh well idc

#

its a mess

#

bro

#

@iron cedar

#

its. worse.

iron cedar
#

wh

rich hound
#

!e

print(
"_hello world_"[--(int(()==())**2)::]
.
replace(
"_",
f"useless var{chr((()==()+()==()*(()==()+()==()*16)))}"[--(int(()==())**2*11)]
)
.
replace(
chr(104),
chr(104)
.
upper()
)
.
replace(
chr(119),
chr(119)
.
upper()
)+chr(
33
)+""
.
join(
chr(
_
)
for
_
in 
[
32,
70,
114,
111,
109,
32,
78,
111,
120,
46
]
)
)
night quarryBOT
#

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

Hello World! From Nox.
night quarryBOT
#

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

Hello World!
rich hound
#

wHY

#

this will make me cry blood

#

make it in shellcode :p

#

lol

#

i do

#

i also know NASM but you know, thats useless

floral meteor
#

hiiii

night quarryBOT
#

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

Hello Worpd!
leaden plinth
#

hello! Can someone say how if its possible to get each pixel values in image?

#

like i need all white pixels, with somekind of coordinates of each

night quarryBOT
knotty delta
#

where can i find resources on esoteric python?

#

!pypi pillow that lib is outdated

night quarryBOT
knotty delta
#

@leaden plinth

#

dont use the lib above

#

i mean the PIL one

leaden plinth
#

thanks guys! no worries with versions

floral meteor
#

i can use it if i like what are you gonna do, come here and stop me? XD

potent cliff
#

Nah the fact that it's probably broken and won't work will

earnest wing
#

It also supports... python 2.4 to 2.7 only

#

so even loading the module will probably fail

#

in fact, it's incompatible with setuptools, so you'll need to install it with manual extra steps

potent cliff
#

Matches the channel title I guess

#

Get PIL working in 3.10 :^)

leaden plinth
#

well I got 8.3.2 installed, seems to be fine... I've biien thinking its much easier) So i have one more problem. I have image with resolution 320x320, how many values can have one pixel?

#

its RGB

golden finch
#

It depends if it's transparent, and the depth of the image.

frozen holly
#

you code like a sith

golden finch
#
>>> example,help=type('',(),{'__sub__':lambda self,other:print('Usage: example [arguments]\nAvailable arguments:\n    --help    | Show this help menu')if other==0 else None})(),type('',(),{'__neg__':lambda self:0})()
>>> example --help
Usage: example [arguments]
Available arguments:
    --help    | Show this help menu
rich hound
#

o.O

#

make it print actual arguments of a command @golden finch

#

like the ones it needs

golden finch
#

problem is that it might be a syntaxerror

rich hound
#

you can try

#

might not work

golden finch
#

proof:

#

!e

command --echo string
night quarryBOT
#

@golden finch :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     command --echo string
003 |                    ^
004 | SyntaxError: invalid syntax
golden finch
#

can't escape syntax error

rich hound
#

hm how would u get required args in a function then :?

#

@golden finch sry for ping ๐Ÿ˜ฌ

golden finch
#

?

#

do you have a code example?

#

what do you mean?

rich hound
#

like

#
def x(get, these, outside_the_function):
    return 1
#

best i could describe it

#

i know its possible, i just dk how

#

hm

golden finch
#

that's a function which takes arguments

#

do you mean like

#

x -get -these -outside_the_function

#

because that's probably possible

frigid shoal
#
In [6]: import inspect

In [7]: def x(get, these, outside_the_function):
   ...:         return 1
   ...:

In [8]: sig = inspect.signature(x)

In [9]: sig.parameters
Out[9]:
mappingproxy({'get': <Parameter "get">,
              'these': <Parameter "these">,
              'outside_the_function': <Parameter "outside_the_function">})```
rich hound
#

o.O

frigid shoal
#
In [13]: get = sig.parameters['get']

In [14]: get.default is not get.empty # or inspect.Parameter.empty
Out[14]: False```(this means it's required)
#

actually

#
In [15]: def x(get, these, outside_the_function, *foo):
    ...:         return 1
    ...:
    ...:

In [16]: sig = inspect.signature(x)

In [17]: foo = sig.parameters['foo']

In [18]: foo.default is not foo.empty
Out[18]: False```in cases like this you could check the kind attribute of the Parameter
rich hound
#

o_o

#

is there a way without external imports

#

@frigid shoal

frigid shoal
#

not sure how

rich hound
#

hm

golden finch
#
def f(a,b,c):
    return 1
[print(i,getattr(f,i))for i in dir(f)]
rich hound
#

wow.

#

@frigid shoal

In [8]: import inspect

In [9]: params = inspect.signature(example)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-35088f8ff0f6> in <module>()
----> 1 params = inspect.signature(example)

AttributeError: 'module' object has no attribute 'signature'
```?
frigid shoal
#

works for me, not sure why you're getting that

rich hound
#

same idk

rich hound
frigid shoal
#

Their code worked for me as well

rich hound
#

ยฏ_(ใƒ„)_/ยฏ

#

strange

#
nox@nksys:~$ python3.8 -V
Python 3.8.12
#

should be working

golden finch
#

weird

rich hound
#

how do i get the python version inside itself?
that makes no sense

next flame
#

@rich hound are you sure ipython is python3 and not python 2

#

check via sys.version

rich hound
#

okay :)

#

my god im dumb its 2.7

#

@next flame

next flame
#

np

rich hound
#

how do i make it 3.8?

next flame
#

pip3 install ipython ig

#

if it says already installed, then just --force-reinstall

rich hound
#

oh ok

#

didnt fix it

#

nvmmm

#

!e

def x(a1, b2, c3):
    return 1

print(", ".join(a for a in __import__("inspect").signature(x).parameters))
night quarryBOT
#

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

a1, b2, c3
floral meteor
#

the a for a in i think is redundant

#

!e ```py
def x(a,b,c):return...
print(','.join(import('inspect').signature(x).parameters))

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

a,b,c
floral meteor
#

so is most of the whitespace you used

#

you only need one newline in that file and one space character

#

and ellipsis is cuter than return 1 ;)

rich hound
#

ok but

#

that works until you need to do a function on it

floral meteor
#

that's what map is for

#

i think

#

!d map

night quarryBOT
#
map

map(function, iterable, ...)```
Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterable* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see [`itertools.starmap()`](https://docs.python.org/3.10/library/itertools.html#itertools.starmap "itertools.starmap").
floral meteor
#

see?

#

@rich hound try this builtin function

rich hound
#

hm?

#

uh

#

ive never used map

snow beacon
#

It's not particularly complicated.```py
In [1]: increment = 1 .add

In [2]: list(map(increment, [1, 2, 3]))
Out[2]: [2, 3, 4]```

golden finch
#

is there a way to escape ```py
*iter(help,0),

?
@floral meteor 
@rugged sparrow 
you guys might know more than me
snow beacon
golden finch
#

Yeah, that's cheating

#

From with the program

earnest wing
#

spawn a thread

#

?

grave rover
#

What's the easiest way to deepcopy a function?

#

I basically need to swap two functions without swapping the objects

snow beacon
#

There could be some edge cases with async or generators, I don't recall.

#

In the simple case it works.```py
In [1]: def foo(): pass
In [2]: foo.code = (lambda x: x + 1).code
In [3]: foo(1)
Out[3]: 2

grave rover
#

I'd also need to swap out the argument count and all that, no?

proper vault
#

that's all in the code object

#

the only thing you may need to also change is __name__ and __qualname__ (do functions even get that)

#

and well, all other attributes the function may have, they can carry arbitrary ones after all

grave rover
#

gotcha

#
    func.__code__, inner.__code__ = inner.__code__, func.__code__
ValueError: read_line() requires a code object with 0 free vars, not 1
#

swapping code: ```py

func.__code__, inner.__code__ = inner.__code__, func.__code__
func.__globals__, inner.__globals__ = inner.__globals__, func.__globals__
func.__closure__, inner.__closure__ = inner.__closure__, func.__closure__
func.__defaults__, inner.__defaults__ = inner.__defaults__, func.__defaults__
func.__kwdefaults__, inner.__kwdefaults__ = inner.__kwdefaults__, func.__kwdefaults__
#

I think I have to use types.FunctionType but I have no clue what's needed for the argdefs field

golden finch
#

types.FunctionType just takes a codeobj, right?

proper vault
#

actually a simpler solution may be just doing

def copy_fn(fn):
    ns = globals().copy()
    exec(f"""
global {fn.__name__}
{inspect.getsource(fn)}
""", ns)
    return ns[fn.__name__]
```won't work on lambdas unless you give them a new name
snow beacon
#

So for kwargs.

grave rover
snow beacon
#

Can I ask what you're hoping to accomplish with this?

grave rover
#

a code injection framework

#

@inject(method=read_line, at=At(value=AtValue.RETURN))
def on_read():
    # TODO: Figure out a good way to pass context and set return value
    pass


@modify_const(method=read_line, 
              at=At(value=AtValue.LOAD,
                    index=0))
def change_prompt():
    return ">>>"


def main():
    while True:
        line = read_line()
        if not line.strip():
            break
        print(f"Read line: {line.strip()}")``` here's some example usage
#

with support for priorities and conflict checking to avoid segfaults, but that means I have to make a wrapper function that applies all modifications at once before first use

#

so my idea was to copy read_line to a dummy function, and set read_line to apply those changes to the dummy function

golden finch
#

wrong channel

grave rover
#

okay newest stupid idea: pre-inject code that calls a function to modify itself the first time it's called

grave rover
#

janky as it sounds, that worked to trigger the function lol

grave rover
#

oh no I need to reimplement that asm library I was working on way back with jumps and stuff

#

this is gonna be pain

grave rover
#

Is there a list of all revisions to the bytecode including what was added/removed in what versions?

sick hound
#

!e

from types import FunctionType
test = (FunctionType(compile('{}', __name__, 'exec'), globals()))

def hi():
    print("hi")

test.a = hi

test.a()
night quarryBOT
#

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

hi
sick hound
#

!e

from types import FunctionType
test = (FunctionType(compile('', __name__, 'exec'), globals()))

def hi():
    print("hi")

test.a = hi

test.a()
night quarryBOT
#

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

hi
sick hound
#

lol

#

!e


test = (lambda test: {})
def hi():
    print("hi")

test.a = hi

test.a()
night quarryBOT
#

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

hi
night quarryBOT
#

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

001 | The Zen of Python, by Tim Peters
002 | 
003 | Beautiful is better than ugly.
004 | Explicit is better than implicit.
005 | Simple is better than complex.
006 | Complex is better than complicated.
007 | Flat is better than nested.
008 | Sparse is better than dense.
009 | Readability counts.
010 | Special cases aren't special enough to break the rules.
011 | Although practicality beats purity.
... (truncated - too many lines)

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

grave rover
#
# Code:
def func(x):
    if x > 10:
        return x / 40
    else:
        return x / 20

# My parser:
[
    LOAD_FAST(id=124, arg='x'), 
    LOAD_CONST(id=100, arg=10), 
    COMPARE_OP(id=107, arg=4), 
    POP_JUMP_IF_FALSE(id=114, arg=Label(0x7f25f2908780)),  # --> 1
    LOAD_FAST(id=124, arg='x'), 
    LOAD_CONST(id=100, arg=40), 
    BINARY_TRUE_DIVIDE(id=27, arg=0), 
    RETURN_VALUE(id=83, arg=0), 
    Label(0x7f25f2908780),  # <-- 1
    LOAD_FAST(id=124, arg='x'), 
    LOAD_CONST(id=100, arg=20), 
    BINARY_TRUE_DIVIDE(id=27, arg=0), 
    RETURN_VALUE(id=83, arg=0), 
    LOAD_CONST(id=100, arg=None), 
    RETURN_VALUE(id=83, arg=0)
]
```pretty happy with this so far
golden finch
#

impressive

#

can't you just extract it from dis.opmap and f.__code__?

#

or are you doing something else?

grave rover
#

there's some wacky stuff going on once you start moving stuff around

#

specifically with jumps

#

then there's the way I want to do code injection where having ops as a list is very useful

#

but right now de- and reserializing a code object is giving me issues

#
# Code:
    dis(f)
    print(f(10))
# Dis:
          0 LOAD_FAST                0 (x)
          2 LOAD_CONST               0 (10)
          4 COMPARE_OP               4 (>)
          6 POP_JUMP_IF_FALSE        8 (to 16)
          8 LOAD_FAST                0 (x)
         10 LOAD_CONST               1 (40)
         12 BINARY_TRUE_DIVIDE
         14 RETURN_VALUE
    >>   16 LOAD_FAST                0 (x)
         18 LOAD_CONST               2 (20)
         20 BINARY_TRUE_DIVIDE
         22 RETURN_VALUE
# Output:
0.0
# Expected:
0.5
grave rover
golden finch
#

oh, so you're actually modifying the source? that's hardcore

grave rover
#

For this project I'm also more or less trying to copy how Java's OWASM works

grave rover
golden finch
#

I thought the length of co_code was fixed

grave rover
#

nope

#

but you can't only change co_code in most cases

golden finch
#

wait, how the hell do you do it then?

#

alloc new memory and change the pointer to co_code?

grave rover
#
Name:              <function>
Filename:          <code>
Argument count:    1
Positional-only arguments: 0
Kw-only arguments: 0
Number of locals:  0
Stack size:        2
Flags:             NOFREE
Constants:
   0: 10
   1: 40
   2: 20
Variable names:
   0: x
``` this all looks correct too, hmm...
grave rover
golden finch
#

oh so just via CodeType.replace

grave rover
#

yeah

#

planning to go back to just using raw CodeType for compat purposes

#

in theory my code would allow backwards compat all the way to 3.0

#

so for every major version since 3.0 I made sure it only adds the ops that are actually present in the current python version

#

Sadly I'll have to do away with type hints if I want to go that far back

golden finch
#

wow

grave rover
#

okay well

#

I'm corrupting the stack somewhere

#
# Code:
def func(x):
    print(x)
    if x > 20:
        return x / 40
    else:
        return x / 20

# Input:
f(10)
# Output:
<built-in function print>
Traceback (most recent call last):
  File "/home/mart/git/pyasm/pyasm/test/test.py", line 37, in <module>
    main()
  File "/home/mart/git/pyasm/pyasm/test/test.py", line 31, in main
    print(f(10))
  File "<code>", line 3, in <function>
TypeError: '>' not supported between instances of 'NoneType' and 'int'
#
# Dis:
  2           0 LOAD_GLOBAL              0 (print)
              2 LOAD_FAST                0 (x)
              4 CALL_FUNCTION            1
              6 POP_TOP

  3           8 LOAD_FAST                0 (x)
             10 LOAD_CONST               0 (20)
             12 COMPARE_OP               4 (>)
             14 POP_JUMP_IF_FALSE       12 (to 24)

  5          16 LOAD_FAST                0 (x)
             18 LOAD_CONST               1 (40)
             20 BINARY_TRUE_DIVIDE
             22 RETURN_VALUE
        >>   24 LOAD_FAST                0 (x)
             26 LOAD_CONST               0 (20)
             28 BINARY_TRUE_DIVIDE
             30 RETURN_VALUE```
rugged sparrow
#

@grave rover is that the bytecode that produced that error?

grave rover
#

yup

#

and it 1:1 matches the correct bytecode

#

oh!

#

that makes

#

a lot of sense

rugged sparrow
#

what does

grave rover
#

wait nvm

#

I thought it broke because None wasn't in the consts

rugged sparrow
#

what const was at index 0

grave rover
#

20

#

ah it was nlocals

rugged sparrow
#

ah

grave rover
#

awesome it works now

#

tomorrow I'll go polish it and whatever

rugged sparrow
#

so whats the goal?

grave rover
#

this is for simple bytecode edits similar to objectweb-asm for java

#

and with this I can make a somewhat reliable code injection mechanism

#
@inject(method=read_line, at=At(value=AtValue.RETURN))
def on_read(ctx):
    # TODO: Figure out a good way to pass context and change return value
    pass


@modify_const(method=read_line,
              at=At(value=AtValue.LOAD,
                    index=0))
def change_prompt():
    return ">>> "
rugged sparrow
#

so itll inject LOAD_CONST(func) CALL_FUNCTION(0)? or will it copy the bytecode of the injected function in

grave rover
#

it will inject method calls and a few other things to get contextual information probably

#

not 100% sure yet

#

but having a low-level library makes writing a high-level library easier :)

#

especially with those damn jumps

tacit dust
#

Hi

rapid sparrow
#

may have found the longest type alias ever

#
CmpKey: typing._GenericAlias = typing.Tuple[int, typing.Tuple[int, ...], typing.Union[pip._vendor.packaging._structures.InfinityType, pip._vendor.packaging._structures.NegativeInfinityType, typing.Tuple[str, int]], typing.Union[pip._vendor.packaging._structures.InfinityType, pip._vendor.packaging._structures.NegativeInfinityType, typing.Tuple[str, int]], typing.Union[pip._vendor.packaging._structures.InfinityType, pip._vendor.packaging._structures.NegativeInfinityType, typing.Tuple[str, int]], typing.Union[pip._vendor.packaging._structures.NegativeInfinityType, typing.Tuple[typing.Union[pip._vendor.packaging._structures.InfinityType, pip._vendor.packaging._structures.NegativeInfinityType, int, str, typing.Tuple[typing.Union[pip._vendor.packaging._structures.InfinityType, pip._vendor.packaging._structures.NegativeInfinityType, int, str], str], typing.Tuple[pip._vendor.packaging._structures.NegativeInfinityType, typing.Union[pip._vendor.packaging._structures.InfinityType, pip._vendor.packaging._structures.NegativeInfinityType, int, str]]], ...]]]
#

it may just be infinitely recursive?

royal sun
#

idk this might be relate

#

d

floral meteor
#

or even iterable unpack

sacred umbra
#

Daily reminder that this channel is cursed

rich hound
#

yes.

#

it is

#

and i contribute to it

golden finch
#

yes

rich hound
#

my old account has some spicy stuff in here

#

but that was compromised :/

#

discord didnt get it back either

rich hound
#

accurate

earnest wing
#

Is this an annotation bug? With __future__ annotations enabled,

a.b: c

tries to evaluate c.

This kind of messes with my cursed plans.

proper vault
#

that does seem like a bug, annotations not working on attribute accesses

earnest wing
#

!e ```py
from future import annotations

int.add: fhadjkfhd

night quarryBOT
#

@earnest wing :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | NameError: name 'fhadjkfhd' is not defined
earnest wing
#

yeah it's not just my version

turbid dewBOT
earnest wing
#

Without assigning

proper vault
#

huh, when you assign it does work

earnest wing
#

Odd

proper vault
#

thats definitely a bug then

earnest wing
#

Well consider it addressed verycool

proper vault
#

oh, that makes more sense

plucky light
#

!e

def cprint(*args,**kwargs):
  print(args[0])
__builtins__.__import__ = cprint

import ello_this_works_poggers
import ello ```
night quarryBOT
#

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

001 | ello_this_works_poggers
002 | ello
plucky light
#

don't know if it is esotoric

#

but it seems cool

golden finch
#

fairly esoteric

lone gust
#

Fun

#

I'm about to put this in live code

#
try:
  klass.__setattr__(None, None, None)
except SpecificException:
  something()

(specificexception and something() will be changed, the cursed part is the setattr)

snow beacon
#
def __builtins__():pass
```Interesting...
#
class __builtins__:
    from builtins import print as __import__
```For some reason this doesn't work either.
#

It's because the __builtins__ object has to subscriptable, which means it can't be a regular class. I don't know of a way to instantiate a class, so no progress has been made.

golden finch
#
__builtins__=type('',(dict,),{})()
earnest wing
#

no expressions

golden finch
#

oh

floral meteor
night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

This is how you instantiate a class
rugged sparrow
#

the goal was no expressions i think

floral meteor
#

huh

rapid sparrow
#
killall -9 python
python
grave rover
#

It works Yay

grave rover
#

next up: Passing arguments from the env to the function if it requests them

vague cairn
#

Impressive!

vague cairn
#

!e ```def imediate(cls, *a, **k):
return cls(*a, **k)

print(builtins, builtins.import)

@imediate
class builtins:
from builtins import print as import

print(builtins, builtins.import)

import what_about_this```

night quarryBOT
#

@vague cairn :x: Your eval job has completed with return code 1.

001 | <module 'builtins' (built-in)> <built-in function __import__>
002 | <__main__.__builtins__ object at 0x7f4b1ff9bdc0> <built-in function print>
003 | Traceback (most recent call last):
004 |   File "<string>", line 12, in <module>
005 | ModuleNotFoundError: No module named 'what_about_this'
shut trail
#

Lmao

kindred herald
shut trail
#

Lol

#

I feel like that would return a WinError

#

Because those folders are protected

#
def contextdispatch(function):
    contexts = {}

    def register(context: str, params_passed: tuple = ()):
        def register_decorator(func):
            contexts[context] = (func, params_passed)

            def running_register(*args, **kwargs):
                return func(*args, **kwargs)

            return running_register

        return register_decorator

    def run_function(*args, **kwargs):
        function_called = stack()[-1].code_context[-1].rstrip('\n')
        for context, func in contexts.items():
            if re.search(pattern=fr"{context}", string=function_called):
                if func[1]:
                    params = re.findall(pattern=fr"{func[1][0]}", string=function_called)
                    if func[1][1] != Any:
                        params = map(func[1][1], params)
                else:
                    params = tuple()
                return func[0](*args, *params, **kwargs)
        else:
            return function(*args, **kwargs)

    run_function.register = register
    return run_function

is this esoteric?

#

I mean it is a decorator for messing around with functions

#

where you can change what function is called based off how the function is called

#

!d functools.singledispatch

night quarryBOT
#

@functools.singledispatch```
Transform a function into a [single-dispatch](https://docs.python.org/3.10/glossary.html#term-single-dispatch) [generic function](https://docs.python.org/3.10/glossary.html#term-generic-function).

To define a generic function, decorate it with the `@singledispatch` decorator. Note that the dispatch happens on the type of the first argument, create your function accordingly:

```py
>>> from functools import singledispatch
>>> @singledispatch
... def fun(arg, verbose=False):
...     if verbose:
...         print("Let me just say,", end=" ")
...     print(arg)
```...
shut trail
#

^ inspired off of this

bitter jacinth
#

Can anyone think of a scenario where del self would actually be possible to use in a somewhat useful way?

class Foo:
    def __init__(self):
        print(self)  # prints <Foo object at 0x...>
        del self
        print(self)  # Raises UnboundLocalError
snow beacon
graceful patrol
thorny tapir
#

damn it

night quarryBOT
#

@thorny tapir :white_check_mark: Your eval job has completed with return code 0.

001 | Failed to import module L
002 | Failed to import module L
thorny tapir
#

oh lol that means u can change default functions n stuff?

golden finch
#

correct

#

!e

__builtins__.__import__=lambda*_,**__:print(_,__)
import math
import time
night quarryBOT
#

@golden finch :white_check_mark: Your eval job has completed with return code 0.

001 | ('math', {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}, {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}, None, 0) {}
002 | ('time', {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'math': None}, {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'math': None}, None, 0) {}
golden finch
#

Where do these other arguments come from?

#

Also, can kwargs be anything else?

#

!e

__builtins__.__import__=lambda*_,**__:print(_,__)
import math
import time

from tkinter import *
def f(x):
  import ctypes
night quarryBOT
#

@golden finch :x: Your eval job has completed with return code 1.

001 | ('math', {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}, {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}, None, 0) {}
002 | ('time', {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'math': None}, {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'math': None}, None, 0) {}
003 | ('tkinter', {'__name__': '__main__', '__doc__': None, '__package
... (truncated - too long)

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

rugged sparrow
#

!e py __builtins__.__import__ = lambda *a, **k: print(a, k) from foo.bar import b as c

night quarryBOT
#

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

001 | ('foo.bar', {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}, {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}, ('b',), 0) {}
002 | Traceback (most recent call last):
003 |   File "<string>", line 2, in <module>
004 | ('io', {'__builtins__': <module 'builtins' (built-in)>}, {'__builtins__': <module 'builtins' (built-in)>}, [], 0) {}
005 | ImportError: cannot import name 'b' from '<unknown module name>' (unknown location)
dire sparrow
#

Oh god.

cerulean rivet
#

guys, is possible doing that without metaclass?```py
class _MetaModel(type):
def len(self):
return self.hack

class Model(metaclass=_MetaModel):
pass

class Player(Model):
hack = 1

len(Player) # 1```

#

how?

night quarryBOT
#

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

1
cerulean rivet
#

this don't changes nothing pithink

#

the difference is only ```py
class Model(metaclass=_MetaModel):
class Model(_MetaModel('Model',(),{})):

#

make a class that supports len

#

i'm using __init_subclass__ of Model

#
import typing

T = typing.TypeVar('T', bound="Model")


class _attribute:
    __slots__ = ()

    def __init__(self) -> None:
        pass

    def __get__(self, *_) -> typing.Any:
        ...

    def __set__(*_) -> None:
        raise AttributeError("you can't set this attribute")


class ModelMeta(type):
    def __len__(self):
        return 1


class Model(metaclass=ModelMeta):
    __models__: typing.ClassVar[dict[str, type[T]]] = {}

    def __init_subclass__(cls, **options) -> None:
        self: T = cls.__mro__[-2]

        if cls.__base__ != self:
            raise RuntimeError("you can't subclass a Model")

        name = options.pop("name", cls.__name__)
        self.__models__[name] = cls

        cls.it = []

        for identifier, annotation in cls.__annotations__.items():
            ...

            descriptor = _attribute()
            setattr(cls, identifier, descriptor)



class Person(Model, name="pessoa"):
    name: str
    age: int


class Book(Model, name="livro"):
    title: str
    author: Person
golden finch
#

typehints
lmao

golden finch
#

What's going on here?

#

!e

original=__builtins__.__build_class__
def build(*args,**kwargs):
  print(args,kwargs)
  return original(*args,**kwargs)

__builtins__.__build_class__=build
import re
night quarryBOT
#

@golden finch :white_check_mark: Your eval job has completed with return code 0.

001 | (<function _C at 0x7fc20a2c9820>, '_C') {}
002 | (<function DynamicClassAttribute at 0x7fc20a2c99d0>, 'DynamicClassAttribute') {}
003 | (<function _GeneratorWrapper at 0x7fc20a2c99d0>, '_GeneratorWrapper') {}
004 | (<function auto at 0x7fc20a2e0670>, 'auto') {}
005 | (<function _EnumDict at 0x7fc20a2e0670>, '_EnumDict', <class 'dict'>) {}
006 | (<function EnumMeta at 0x7fc20a2e0670>, 'EnumMeta', <class 'type'>) {}
007 | (<function Enum at 0x7fc20a2e0670>, 'Enum') {'metaclass': <class 'enum.EnumMeta'>}
008 | (<function IntEnum at 0x7fc20a2e0670>, 'IntEnum', <class 'int'>, <enum 'Enum'>) {}
009 | (<function Flag at 0x7fc20a2e19d0>, 'Flag', <enum 'Enum'>) {}
010 | (<function IntFlag at 0x7fc20a2e19d0>, 'IntFlag', <class 'int'>, <enum 'Flag'>) {}
011 | (<function error at 0x7fc20a2e3d30>, 'error', <class 'Exception'>) {}
... (truncated - too many lines)

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

golden finch
#

so that's the original builtin

#

!e

original=__builtins__.__build_class__
def build(f,n,*bases,**kwargs):
  old=original(f,n,*bases,**kwargs)
  if 'metaclass' in kwargs:
    return kwargs['metaclass'](n,bases,dict(old.__dict__))
  else:
    return type(n,bases,dict(old.__dict__))

__builtins__.__build_class__=build
import re
night quarryBOT
#

@golden finch :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 10, in <module>
003 |   File "/usr/local/lib/python3.9/re.py", line 124, in <module>
004 |     import enum
005 |   File "/usr/local/lib/python3.9/enum.py", line 664, in <module>
006 |     class Enum(metaclass=EnumMeta):
007 |   File "<string>", line 3, in build
008 |   File "/usr/local/lib/python3.9/enum.py", line 169, in __prepare__
009 |     enum_dict = _EnumDict()
010 |   File "/usr/local/lib/python3.9/enum.py", line 82, in __init__
011 |     super().__init__()
... (truncated - too many lines)

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

golden finch
#

there we go

#

why's that error happening?

rapid sparrow
golden finch
#

I wrote the code in the first example

#

The thing is

#

Why doesn't the second work?

#

I use the original __build_class__ function to get the namespace

#

or is it a mistake in metaclasses?

#

!e

original=__builtins__.__build_class__
def build(f,n,*bases,**kwargs):
  old=original(f,n,*bases,**kwargs)
  return type(n,bases,dict(old.__dict__))

__builtins__.__build_class__=build
import re
night quarryBOT
#

@golden finch :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 7, in <module>
003 |   File "/usr/local/lib/python3.9/re.py", line 124, in <module>
004 |     import enum
005 |   File "/usr/local/lib/python3.9/enum.py", line 664, in <module>
006 |     class Enum(metaclass=EnumMeta):
007 |   File "<string>", line 3, in build
008 |   File "/usr/local/lib/python3.9/enum.py", line 169, in __prepare__
009 |     enum_dict = _EnumDict()
010 |   File "/usr/local/lib/python3.9/enum.py", line 82, in __init__
011 |     super().__init__()
... (truncated - too many lines)

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

golden finch
#

same error

#


Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/usr/local/lib/python3.9/re.py", line 124, in <module>
    import enum
  File "/usr/local/lib/python3.9/enum.py", line 664, in <module>
    class Enum(metaclass=EnumMeta):
  File "<string>", line 3, in build
  File "/usr/local/lib/python3.9/enum.py", line 169, in __prepare__
    enum_dict = _EnumDict()
  File "/usr/local/lib/python3.9/enum.py", line 82, in __init__
    super().__init__()
TypeError: super(type, obj): obj must be an instance or subtype of type

golden finch
# golden finch !e ```py original=__builtins__.__build_class__ def build(f,n,*bases,**kwargs): ...

@rapid sparrow in this example, what am I doing wrong with my reimplementation? it doesn't appear to have anything obviously wrong with it

code reproduced below

original=__builtins__.__build_class__
def build(f,n,*bases,**kwargs):
  old=original(f,n,*bases,**kwargs)
  if 'metaclass' in kwargs:
    return kwargs['metaclass'](n,bases,dict(old.__dict__))
  else:
    return type(n,bases,dict(old.__dict__))

__builtins__.__build_class__=build
import re
rapid sparrow
#

!e

original=__import__("builtins").__build_class__
def build(func, name, *bases, **kwargs):
  callee = kwargs["metaclass"] if "metaclass" in kwargs else type
  ns = {}
  print(f"exec({func.__code__=}, {ns=}, func.__globals__=)")
  global __name__
  __name__ = func.__module__
  exec(func.__code__, func.__globals__)
  print(f"callee({name=}, {bases=}, ns=)")
  cls = callee(name, bases, ns)
  print(f"{cls=}")
  return cls
__import__("builtins").__build_class__=build
import re
night quarryBOT
#

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

001 | exec(func.__code__=<code object _C at 0x7fdc6884bbe0, file "/usr/local/lib/python3.9/types.py", line 39>, ns={}, func.__globals__=)
002 | callee(name='_C', bases=(), ns=)
003 | cls=<class 'types._C'>
004 | Traceback (most recent call last):
005 |   File "<string>", line 14, in <module>
006 |   File "/usr/local/lib/python3.9/re.py", line 124, in <module>
007 |     import enum
008 |   File "/usr/local/lib/python3.9/enum.py", line 2, in <module>
009 |     from types import MappingProxyType, DynamicClassAttribute
010 |   File "/usr/local/lib/python3.9/types.py", line 41, in <module>
011 |     MethodType = type(_C()._m)
... (truncated - too many lines)

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

rapid sparrow
#

!e

import sys
def build(func, name, *bases, **kwargs):
  callee = kwargs["metaclass"] if "metaclass" in kwargs else type
  ns = {}
  print(f"exec({func.__code__=}, {ns=}, func.__globals__=)")
  global __name__
  __name__ = func.__module__
  print(f"callee({name=}, {bases=}, {ns=})")
  exec(func.__code__, sys.modules[func.__module__].__dict__, ns)
  print(f"callee({name=}, {bases=}, {ns=})")
  cls = callee(name, bases, ns)
  sys.modules[func.__module__].__dict__[name] = cls
  print(f"{cls=}")
  return cls
__builtins__.__build_class__=build
import re
import inspect
night quarryBOT
#

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

001 | exec(func.__code__=<code object _C at 0x7f48dcaa7b30, file "/usr/local/lib/python3.9/types.py", line 39>, ns={}, func.__globals__=)
002 | callee(name='_C', bases=(), ns={})
003 | callee(name='_C', bases=(), ns={'__module__': 'types', '__qualname__': '_C', '_m': <function _C._m at 0x7f48dca9b940>})
004 | cls=<class 'types._C'>
005 | exec(func.__code__=<code object DynamicClassAttribute at 0x7f48dcaa9500, file "/usr/local/lib/python3.9/types.py", line 149>, ns={}, func.__globals__=)
006 | callee(name='DynamicClassAttribute', bases=(), ns={})
007 | callee(name='DynamicClassAttribute', bases=(), ns={'__module__': 'types', '__qualname__': 'DynamicClassAttribute', '__doc__': "Route attribute access on a class to __getattr__.\n\n    This is a descriptor, used to define attributes that act differently when\n    accessed through an instance and through a class.  Instance access remains\n    normal, but access to an attribute through a class will be routed to the\n    class's __getattr__ m
... (truncated - too long, too many lines)

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

rapid sparrow
golden finch
#

?

rapid sparrow
#

in my version it dies in some code that's running while EnumMeta is set up (code trying to use .attr syntax on 'classdict')

#

setting up Enum with metaclass=EnumMeta, I mean

rapid sparrow
grave rover
#
  2           0 LOAD_CONST               1 (<function on_read at 0x7f41840e4dc0>)
              2 LOAD_CONST               2 (<class 'mixin.callback.CallbackInfo'>)
              4 CALL_FUNCTION            0
              6 CALL_FUNCTION            1
              8 POP_TOP
             10 LOAD_GLOBAL              0 (input)
             12 LOAD_CONST               3 (<function change_prompt at 0x7f41840e4ee0>)
             14 LOAD_FAST                0 (p)
             16 CALL_FUNCTION            1
             18 CALL_FUNCTION            1
             20 RETURN_VALUE
Traceback (most recent call last):
  File "/home/mart/git/pyasm/pymixin/test/test.py", line 28, in <module>
    main()
  File "/home/mart/git/pyasm/pymixin/test/test.py", line 21, in main
    line = read_line()
  File "/home/mart/git/pyasm/pymixin/test/test_lib.py", line -1, in read_line
TypeError: 'int' object is not callable
#

I dont even know anymore

rapid sparrow
#

lmao

rapid sparrow
night quarryBOT
#

Python/bltinmodule.c line 105

builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,```
grave rover
#

I'm not, or at least I don't think I am

#

no clue where in the bytecode that happens

#

an int

#

which is a parameter to change_prompt

#

that's the output from dis, yes

#

it's also 1:1 with what I expect the bytecode to be

#

well uh

#

code injection

#

kinda hard to debug

#

wait I think I know what the issue is

#

hmm

grave rover
#

so the wacky thing is:

  • I initially inject some code
  • That code applies all modifications to itself
  • When it returns the bytecode will have changed and it'll be calling an int
#

Before injection:py 2 0 LOAD_CONST 2 (<function get_wrapper.<locals>.inject at 0x7f42013ace50>) 2 CALL_FUNCTION 0 4 POP_TOP 6 LOAD_CONST 3 (<function read_line at 0x7f42013ac8b0>) 8 LOAD_FAST 0 (p) 10 CALL_FUNCTION 0 # Call modified self 12 RETURN_VALUE 14 LOAD_GLOBAL 0 (input) 16 LOAD_CONST 1 ('> ') 18 CALL_FUNCTION 1 20 RETURN_VALUE After injection: ```py
2 0 LOAD_CONST 1 (False)
2 POP_JUMP_IF_FALSE 7 (to 14) # Jump to the function itself
4 LOAD_CONST 1 (False)
6 NOP
8 NOP
10 NOP
12 RETURN_VALUE # Match RETURN_VALUE in previous function
>> 14 LOAD_CONST 2 (<function on_read at 0x7f42013acdc0>)
16 LOAD_CONST 3 (<class 'mixin.callback.CallbackInfo'>)
18 CALL_FUNCTION 0
20 CALL_FUNCTION 1
22 POP_TOP
24 LOAD_GLOBAL 0 (input)
26 LOAD_CONST 4 (<function change_prompt at 0x7f42013acee0>)
28 LOAD_FAST 0 (p)
30 CALL_FUNCTION 1
32 CALL_FUNCTION 1
34 RETURN_VALUE

#

yet it still happens...

golden finch
#

maybe one of those functions is pushing something to the stack that you're not expecting

rapid sparrow
golden finch
#

ah

#

thanks, will test that out

grave rover
#

because it'd have its own stack

rapid sparrow
# golden finch ah

maybe the problem might be that you call the metaclass without calling __prepare__ first?

golden finch
#

Ah, back to the CCC

#

that might be it

rapid sparrow
# golden finch thanks, will test that out
def build_class(func, name, *bases, metaclass=None, **kwds):
    if metaclass is None:
        metaclass = _extract_metaclass(bases)  # may raise an exception
    prepare = getattr(metaclass, "__prepare__", None)
    if prepare:
        namespace = prepare(name, bases, **kwds)
    else:
        namespace = {}
    newnamespace = func(namespace)
    if newnamespace is not None:
        namespace = newnamespace
    return metaclass(name, bases, namespace, **kwds)

def _extract_metaclass(bases):
    if not bases:
        return type
    # XXX Should we do the "winner" calculation here?
    return bases[0].__class__  # or type(bases[0])?

Guido himself wrote this one and it gets the same error, lol

golden finch
#

okay so it's a bug

floral meteor
#

what's a bug?

rapid sparrow
#

in 3.9 and 3.11 at least

#

i'd like to know if there's a way to intercept the creation of BaseException instances so I can print all the exceptions happening

#

possible?

#

there's a metric ton of them, judging by running python to the prompt and setting a breakpoint on

int PyException_SetTraceback(PyObject *, PyObject *)
#

184 exceptions with full tracebacks to get to >>>

#

mostly KeyError (looking in sys.modules) and various FileNotFoundError from the import system

grave rover
rapid sparrow
#

i don't think it's particular to my system or anything, just wondered what others thought

floral meteor
#

what's wrong with __build_class__?

golden finch
#

the example implementation doesn't even work

grave rover
#

sort of, read_line is the function I inject code into, and the resulting bytecode is there

grave rover
rapid sparrow
grave rover
#

pycharm doesn't seem to have a way to target that easily

#

ah

rapid sparrow
#

you have to be able to set a breakpoint in C, i don't know if it's possible in PyCharm?

grave rover
#

in pycharm you just click on the left of some python code lol

rapid sparrow
#

well any native debugger really i guess, that function is exported so even like perf, valgrind, etc should see it

#

it would be great if there's a way to hook into similar in python

#

maybe pdb lets you break on BaseException.__init__ or on setting the __traceback__ attribute, but I don't know PDB very well

rapid sparrow
grave rover
#

yeah so uh

#

I need to inject into the ceval.c file somewhere

rapid sparrow
#

theres a Notifications box too in PyCharm that defaults to just "Terminate", you probably want "Always" also checked

rugged sparrow
rapid sparrow
#

omg it worked

#
>>> import fishhook
>>> @fishhook.hook(BaseException)
... def __init__(self, *args, **kwargs):
...   print(f"Got exception: {self}({args})")
...   return fishhook.orig(self, *args, **kwargs)
...
>>> raise BaseException("hello")
Got exception: hello(('hello',))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
BaseException: hello
>>>
>>> raise RuntimeError("hello")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: hello
#

i guess you would need to hook the specific class?

rugged sparrow
#

yea one sec imma write a demo

#

yea you need to hook them specifically

#

im gonna try using my lowlevel hook to hook the C function tho

rapid sparrow
#

i was just gonna try to create the hooks in a loop, since most of the exception types are in builtins

rugged sparrow
#

that will work for most of them, but some are used for general control flow so you run into fatal recursion issues

#

and yea i wrote fishhook but im gonna use my asm_hook code to try and hook the underlying C functions

rapid sparrow
#

this worked:

import fishhook
def __init__(self, *args, **kwargs):
    print(f"Got exception: {self}({args})")
    return fishhook.orig(self, *args, **kwargs)

for _, exc_type in inspect.getmembers(builtins, lambda m: inspect.isclass(m) and  issubclass(m,BaseException)):
    fishhook.hook(exc_type)(__init__)
rapid sparrow
#

i didnt think that would be possible without a debugger, very neat

#

already revealed an AttributeError that was unintentionally suppressed in some code I was working on

rugged sparrow
#

In theory with my asm_hook code you could do a breakpoint like gdb

grave rover
#

okay figured out my issue

rapid sparrow
#

does it rewrite instructions?

rugged sparrow
#

It's on my GitHub in pysnippets

#

And yea it patches the machine code at runtime

rapid sparrow
#

nice

grave rover
#
def read_line() -> str:
    return input("> ")

@inject(method=read_line, at=At(value=AtValue.HEAD))
def on_read(ci: CallbackInfo):
    print("Hello Mixin :)")


@modify_const(method=read_line,
              at=At(value=AtValue.LOAD,
                    target="> "))
def change_prompt():
    return ">>> "


i = 0
@redirect(method=read_line,
          at=At(value=AtValue.INVOKE,
                target=input))
def redirected_input(prompt: str):
    global i
    i = i + 1
    return input("{0} {1}".format(i, prompt))
``` ```
Hello Mixin :)
1 >>> a
Read line: a
Hello Mixin :)
2 >>> b
Read line: b
Hello Mixin :)
3 >>> c
Read line: c
Hello Mixin :)
4 >>> 
```Pretty happy so far
rugged sparrow
#

is it posted anywhere?

floral meteor
#

lol iostream hacks

grave rover
#

Then I'll need to make a package name request

grave rover
#

How do freevars/cellvars work?

rapid sparrow
# grave rover How do freevars/cellvars work?

in the case of cellvars, it's basically a pointer to a variable used in multiple scopes (like a function foo and nested_foo). The variables get dereferenced by extra sequences of bytecode the compiler emits, instead of accessed directly like a normal variable

#

freevars are unresolved names afaik, that can work if an attribute is added by that name to a parent scope before the function with the freevar gets run

#

you can find the cell objects if you look at __closure__ on such a function

grave rover
#

so e.g.

#
def make_func(prompt):
    def get_input() -> str:
        return input(prompt)
    return get_input```
#

here prompt is a freevar accessed by the *_DEREF ops

#

what would an example of a cellvar be? (and what opcodes relate to cellvars?)

sick hound
#

My vs code terminal isn't showing any output can anyone plz help?

rapid sparrow
grave rover
#

oh

#

oh no

#

this is not gonna be fun

rapid sparrow
#
>>> def foo(a):
...   def nested():
...     return a
...   return nested
...
>>> n = foo(70); n
<function foo.<locals>.nested at 0x7ff797d670>
>>> n.__closure__
(<cell at 0x7ff7b04670: int object at 0x7ff7c8a210>,)
>>> c = n.__closure__[0]
>>> c.cell_contents
70
>>> foo.__code__.co_cellvars
('a',)
>>> n.__code__.co_freevars
('a',)
>>> n.__code__.co_cellvars
()
#

its a freevar in the nested func and a cellvar in the outer one, looks like

#

but it seems like nested must have special opcodes to access ut via the cell

#
>>> dis.dis(foo)
  2           0 LOAD_CLOSURE             0 (a)
              2 BUILD_TUPLE              1
              4 LOAD_CONST               1 (<code object nested at 0x7ff7a13500, file "<stdin>", line 2>)
              6 LOAD_CONST               2 ('foo.<locals>.nested')
              8 MAKE_FUNCTION            8 (closure)
             10 STORE_FAST               1 (nested)

  4          12 LOAD_FAST                1 (nested)
             14 RETURN_VALUE

Disassembly of <code object nested at 0x7ff7a13500, file "<stdin>", line 2>:
  3           0 LOAD_DEREF               0 (a)
              2 RETURN_VALUE
rapid sparrow
#

and LOAD_CLOSURE for cellvars maybe

#

same deal for your make_func:

>>> dis.dis(make_func)
  2           0 LOAD_GLOBAL              0 (str)
              2 LOAD_CONST               1 (('return',))
              4 BUILD_CONST_KEY_MAP      1
              6 LOAD_CLOSURE             0 (prompt)
              8 BUILD_TUPLE              1
             10 LOAD_CONST               2 (<code object get_input at 0x7ff766a240, file "<stdin>", line 2>)
             12 LOAD_CONST               3 ('make_func.<locals>.get_input')
             14 MAKE_FUNCTION           12 (annotations, closure)
             16 STORE_FAST               1 (get_input)

  4          18 LOAD_FAST                1 (get_input)
             20 RETURN_VALUE

Disassembly of <code object get_input at 0x7ff766a240, file "<stdin>", line 2>:
  3           0 LOAD_GLOBAL              0 (input)
              2 LOAD_DEREF               0 (prompt)
              4 CALL_FUNCTION            1
              6 RETURN_VALUE
grave rover
#

I see

floral meteor
#

im learning java and i feel like im back to coding like a noob, only i already know these algorithms, just not the java code for them

#

it's like in path of exile when you gotta go through the whole map again from the start, but it's all different, and much harder

grave rover
#

should I make un-wrapping wraps a feature in this or leave that to the user

snow beacon
bronze sorrel
#

tf is this

tribal moon
#

Java is already esoteric

rapid sparrow
#

its hard to think what would be esoteric java

#

class AbstractClassAwareSecurityBeanUtils

rapid sparrow
next flame
#

one * at the beginning I think?

#

instead of **

#

yes

#

I am responding to your error

#

because ** is for dict-like mappings

#

which map() is not

night quarryBOT
golden finch
#

hmm yes (){}[]

floral meteor
#

It converts a = a + 1 to ++a

#

I tried using finalize to hang java but i couldnt find the relevant implements object

golden finch
#
<function <lambda>.<locals>.<lambda> at 0x0000018677E7E040>

this is unpleasant

night quarryBOT
#

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

<function <lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>.<locals>.
... (truncated - too long)

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

golden finch
#

w h a t

#

is that the limit?

#

that if clause

golden finch
#
operator=lambda _:lambda*__:_(*_(*__))
golden finch
#

this can be used to segfault... what?

#

if you do it with 10k

#

!e

unpleasant=lambda x:exec("raise BaseException('no')")if x<1else eval('('+'lambda:'*(x+1)+'0)'+'()'*x)
print(unpleasant(100000))
night quarryBOT
#

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

[No output]
golden finch
#

why?

#

probably

#

!e

exec('()'*7**6)
night quarryBOT
#

@golden finch :warning: Your eval job timed out or ran out of memory.

[No output]
golden finch
#

no, it's definitely a segfault

late quail
#

print 'hello'

#

print( 'hello')

frigid wharf
#

!e py unpleasant=lambda x:exec("raise BaseException('no')")if x<1else eval('('+'lambda:'*(x+1)+'0)'+'()'*x) print(unpleasant(1500))

night quarryBOT
#

@frigid wharf :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 <lambda>
004 | RecursionError: maximum recursion depth exceeded during compilation
golden finch
#

Not for large values of x

#

I think

#

ah

grave rover
rapid sparrow
rapid sparrow
rapid sparrow
grave rover
rapid sparrow
#

crashes during tokenization, looks like?

#

10,000 it could handle but not 100,000 ๐Ÿ˜‚

rapid sparrow
#

looks like they moved Unsafe to the jdk.unsupported module in J11, so I guess if it's still there now, they effectively won't be removing it

#

lmao

grave rover
rapid sparrow
grave rover
#

Gonna see about pypi releases later

rugged sparrow
#

Sweet I'll take a look

grave rover
#

well uh

#

I already identified some issues with it

#

jumps in pyasm are not 100% correct yet

#

and it's a mess

rapid sparrow
grave rover
#

hm?

#

what's the issue?

golden finch
night quarryBOT
#

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

<class '__main__.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A
... (truncated - too long)

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

rapid sparrow
#

tokenizer bug bounty

#

here I come

#

jk

night quarryBOT
#

@sick hound :warning: Your eval job timed out or ran out of memory.

[No output]
turbid dewBOT
golden finch
#

waht?

rapid sparrow
#

stack space

#

seems like

dire galleon
#

?

rapid sparrow
#

whats it not doing right?

fiery hare
#

!e

#include <stdint.h>
#include <stdio.h>

#/* pre-declare types and functions */
void: (type) = (type) ("(void *)0"),
int16_t: (type) = (type) (int(16))(),
int32_t: (type) = (type) (int(32))(),
puts = (print),
printf: ((str) := void) = (puts),

#/* confirm function and variable declarations */
[[void]] = (void),
[[total]] = (int32_t),
[[i]] = (int32_t),
[[puts]] = (puts),
[[printf]] = (printf),

#/* ensure forwards and backwards compatibility */
import __future__ as __past__
#define FUTURE PAST
#define PAST FUTURE

#/* output a formatted string to stdout */
def printf(s, __VA_ARGS__) -> (void) :{
    (void) (puts((void).__mod__(s, __VA_ARGS__), end=((void).__new__)(void))),
}

#/*******************************************************
# * SUMMATION SCRIPT                                    *
# *******************************************************
# * Sum up all the natural numbers up to 6. The result  *
# * should be 0 + 1 + 2 + 3 + 4 + 5 + 6 = 21.           *
# *******************************************************/

#/* print numbers from 0 to 6 */
int32_t: i = 0,
while (i <= 6) :{
    (void) (printf(" %d\n", i)),
    (i := i + 1),
}

(void) (puts("__")),

#/* sum up numbers from 0 to 6 */
int32_t: total = 0,
int32_t: i = 0,
for (int32_t) in (i <- 0, i <= 6, ++i) :{
    (total := total + i),
}

(void) (printf("%d\n", total)),
night quarryBOT
#

@fiery hare :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 8
002 |     puts: ((str) := void) = (print),
003 |             ^
004 | SyntaxError: cannot use assignment expressions with name
fiery hare
#

!e

#include <stdint.h>
#include <stdio.h>

#/* pre-declare types and functions */
void: (type) = (type) ("(void *)0"),
int16_t: (type) = (type) (int(16))(),
int32_t: (type) = (type) (int(32))(),
puts = (print),
printf = (puts),

#/* confirm function and variable declarations */
[[void]] = (void),
[[total]] = (int32_t),
[[i]] = (int32_t),
[[puts]] = (puts),
[[printf]] = (printf),

#/* ensure forwards and backwards compatibility */
import __future__ as __past__
#define FUTURE PAST
#define PAST FUTURE

#/* output a formatted string to stdout */
def printf(s, __VA_ARGS__) -> (void) :{
    (void) (puts((void).__mod__(s, __VA_ARGS__), end=((void).__new__)(void))),
}

#/*******************************************************
# * SUMMATION SCRIPT                                    *
# *******************************************************
# * Sum up all the natural numbers up to 6. The result  *
# * should be 0 + 1 + 2 + 3 + 4 + 5 + 6 = 21.           *
# *******************************************************/

#/* print numbers from 0 to 6 */
int32_t: i = 0,
while (i <= 6) :{
    (void) (printf(" %d\n", i)),
    (i := i + 1),
}

(void) (puts("__")),

#/* sum up numbers from 0 to 6 */
int32_t: total = 0,
int32_t: i = 0,
for (int32_t) in (i <- 0, i <= 6, ++i) :{
    (total := total + i),
}

(void) (printf("%d\n", total)),
night quarryBOT
#

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

001 |  0
002 |  1
003 |  2
004 |  3
005 |  4
006 |  5
007 |  6
008 | __
009 | 21
fiery hare
#

@terse mortar this is the worst thing I've ever experienced.

terse mortar
#

That is amazing

fiery hare
#

no it's not

terse mortar
#

Yes it is

fiery hare
#

I'm so fucking upset right now.

#
#/* ensure forwards and backwards compatibility */
import __future__ as __past__
#define FUTURE PAST
#define PAST FUTURE
terse mortar
#

Makes sense

#

I love doing js in python

sly root
night quarryBOT
#

@sick hound :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | MemoryError
#

@sick hound :warning: Your eval job timed out or ran out of memory.

[No output]
#

@sick hound :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 'psutil'
#

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

[No output]
thorny tapir
grave rover
#

not sure if I should be glad or worried that someone has plans for my code injection framework

#

I did finally make a somewhat decent readme though

golden finch
grave rover
#

oh god you're using commas to secretly make tuples

golden finch
#

so that's what the commas do?

grave rover
#

yeah

golden finch
#

wow

#

high-tier black magic

grave rover
# golden finch high-tier black magic

how black magic is it compared to this ```py

from mixin import *

def return_n_squared(n):
... return n * n
...
@inject(method=return_n_squared, at=At(value=AtValue.RETURN), cancellable=True)
... def return_n_cubed_instead(callback_info: CallbackInfo):
... n = (callback_info.return_value0.5)
... callback_info.set_return(n
3)
...
return_n_squared(10)
1000.0

golden finch
#

less so

#

they are both black magic in different ways

grave rover
#

missing a )

night quarryBOT
#

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

001 |  0
002 |  1
003 |  2
004 |  3
005 |  4
006 |  5
007 |  6
008 | __
009 | 21
steep herald
#

!e print("geh")

night quarryBOT
#

@steep herald :white_check_mark: Your eval job has completed with return code 0.

geh
steep herald
#

!e

S = "a"
key = 1097
print(chr(ord(S)+key))
#

!e
S = "ag"
key = 1097
print(chr(ord(S)+key))

sick hound
#

Can you write a "Hello, World!" Python program where no characters with holes in them are used? lirikHMM so #%DOo09qaA etc not allowed

sick hound
#

correct

night quarryBOT
#

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

Hello, World!
earnest wing
#

p

sick hound
#

If it's easier try only characters with holes in them lirikA

#

comeon, you've got in with try is if chr, uhh

#

yeah, it might be impossible lirikLUL

earnest wing
#

!e ```py
{}["H"+chr(1111//11)+"ll"+chr(111)+", W"+chr(111)+"rl"+chr(73+27)+"!"]

night quarryBOT
#

@earnest wing :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | KeyError: 'Hello, World!'
knotty delta
#

!e

print(["H"+chr(1111//11)+"ll"+chr(111)+", W"+chr(111)+"rl"+chr(73+27)+"!"])
night quarryBOT
#

@knotty delta :white_check_mark: Your eval job has completed with return code 0.

['Hello, World!']
sly root
#

!e ```py
print(bytes([0x18*int(float('0.0'+str(int('0x249e',16)+0x1))*0x20),int(float(str(0x5)+'.'+str(int('0x216ff33c00f0f3',16)))*0x11),int(float(str(0x1)+'.'+str(int('0x32dc227a421af',16)))*int(float(str(0x4)+'.0'+str(int('0x40f6c2a076db',16)))*0xe)),int(float(str(0x1)+'.'+str(int('0x32dc227a421af',16)))*int(float(str(0x4)+'.0'+str(int('0x40f6c2a076db',16)))*0xe)),int(float(str(0x0)+'.'+str(0x0)+str(0x0)+str(int('0x299b48154dfd3e',16)))*int(float(str(0x46)+'.'+str(int('0x16ba2e55f4a',16)))*0x547))]))

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

b'Hello'
cerulean rivet
#

why this work???py ๐“น๐“ป๐“ฒ๐“ท๐“ฝ(๐“ฌ๐“ฑ๐“ป(97)+๐“ฌ๐“ฑ๐“ป(98)+๐“ฌ๐“ฑ๐“ป(99)+๐“ฌ๐“ฑ๐“ป(100)+๐“ฌ๐“ฑ๐“ป(101)+๐“ฌ๐“ฑ๐“ป(102)+๐“ฌ๐“ฑ๐“ป(103)+๐“ฌ๐“ฑ๐“ป(104)+๐“ฌ๐“ฑ๐“ป(105)+๐“ฌ๐“ฑ๐“ป(106)+๐“ฌ๐“ฑ๐“ป(107)+๐“ฌ๐“ฑ๐“ป(108)+๐“ฌ๐“ฑ๐“ป(109)+๐“ฌ๐“ฑ๐“ป(110)+๐“ฌ๐“ฑ๐“ป(111)+๐“ฌ๐“ฑ๐“ป(112)+๐“ฌ๐“ฑ๐“ป(113)+๐“ฌ๐“ฑ๐“ป(114)+๐“ฌ๐“ฑ๐“ป(115)+๐“ฌ๐“ฑ๐“ป(116)+๐“ฌ๐“ฑ๐“ป(117)+๐“ฌ๐“ฑ๐“ป(118)+๐“ฌ๐“ฑ๐“ป(119)+๐“ฌ๐“ฑ๐“ป(120)+๐“ฌ๐“ฑ๐“ป(121)+๐“ฌ๐“ฑ๐“ป(122)+๐“ฌ๐“ฑ๐“ป(65)+๐“ฌ๐“ฑ๐“ป(66)+๐“ฌ๐“ฑ๐“ป(67)+๐“ฌ๐“ฑ๐“ป(68)+๐“ฌ๐“ฑ๐“ป(69)+๐“ฌ๐“ฑ๐“ป(70)+๐“ฌ๐“ฑ๐“ป(71)+๐“ฌ๐“ฑ๐“ป(72)+๐“ฌ๐“ฑ๐“ป(73)+๐“ฌ๐“ฑ๐“ป(74)+๐“ฌ๐“ฑ๐“ป(75)+๐“ฌ๐“ฑ๐“ป(76)+๐“ฌ๐“ฑ๐“ป(77)+๐“ฌ๐“ฑ๐“ป(78)+๐“ฌ๐“ฑ๐“ป(79)+๐“ฌ๐“ฑ๐“ป(80)+๐“ฌ๐“ฑ๐“ป(81)+๐“ฌ๐“ฑ๐“ป(82)+๐“ฌ๐“ฑ๐“ป(83)+๐“ฌ๐“ฑ๐“ป(84)+๐“ฌ๐“ฑ๐“ป(85)+๐“ฌ๐“ฑ๐“ป(86)+๐“ฌ๐“ฑ๐“ป(87)+๐“ฌ๐“ฑ๐“ป(88)+๐“ฌ๐“ฑ๐“ป(89)+๐“ฌ๐“ฑ๐“ป(90)+๐“ฌ๐“ฑ๐“ป(33)+๐“ฌ๐“ฑ๐“ป(34)+๐“ฌ๐“ฑ๐“ป(35)+๐“ฌ๐“ฑ๐“ป(36)+๐“ฌ๐“ฑ๐“ป(37)+๐“ฌ๐“ฑ๐“ป(38)+๐“ฌ๐“ฑ๐“ป(39)+๐“ฌ๐“ฑ๐“ป(42)+๐“ฌ๐“ฑ๐“ป(44)+๐“ฌ๐“ฑ๐“ป(46)+๐“ฌ๐“ฑ๐“ป(47)+๐“ฌ๐“ฑ๐“ป(58)+๐“ฌ๐“ฑ๐“ป(59)+๐“ฌ๐“ฑ๐“ป(60)+๐“ฌ๐“ฑ๐“ป(61)+๐“ฌ๐“ฑ๐“ป(62)+๐“ฌ๐“ฑ๐“ป(63)+๐“ฌ๐“ฑ๐“ป(64)+๐“ฌ๐“ฑ๐“ป(91)+๐“ฌ๐“ฑ๐“ป(93)+๐“ฌ๐“ฑ๐“ป(94)+๐“ฌ๐“ฑ๐“ป(95)+๐“ฌ๐“ฑ๐“ป(96)+๐“ฌ๐“ฑ๐“ป(123)+๐“ฌ๐“ฑ๐“ป(124)+๐“ฌ๐“ฑ๐“ป(125)+๐“ฌ๐“ฑ๐“ป(126))

cerulean rivet
#

hmmm

urban cradle
#
while True:
 print(c:=(lambda x:x[::-1])(input()))
 if input()=='c':__import__("clpbrd").c(c);

when you golf too much and dont understand your own program anymore

rugged sparrow
#

seems like you're taking in a line of input, reversing it and storing it into c

#

then getting input again, if its c you copy the reversed text to the clipboard?

urban cradle
#

its a program to reverse text

#

you need to take an input, modify it, then print it

#

true ig

#

i can get rid of the print and have it automatically copy to my keyboard

#

but that would count as removing features so eh

#
### Reverse text to fix RTL text in outdated programs###
### Or you can use it for other things I do not care ###

import pyperclip

# Function to reverse input text, input text = x #

def reverse(x):
    return x[::-1]

# Clear junk, only works in Windows command prompt #
clear = lambda: os.system('cls')

# Loop #
active = True
while active == True:
    # Print a barrier for aesthetic reasons #
    print("\n##############################################################\n CHIPS REVERSER    NEW INPUT \n##############################################################\n")

     # Asks for input then creates barrier (asthetic) and a new line to write input text in #
    valueentered = input(str("Please enter your string to reverse \n ---------------------------------------------- \n"))

     # Once entered, print a new barrier and a new line for the output #
    print(" ---------------------------------------------- \n")

    # Use function to reverse text #
    valueoutput = reverse(valueentered)

    # Print output aesthetically #
    print("Output \n---------------------------------------------- \n", valueoutput, " \n---------------------------------------------- \n")


    # Ask for command #
    cask = input(str("Enter ""c"" to copy or ""e"" to end program : "))


    # Check input for command, ignore if no command received #
    if cask == ("c"):
        pyperclip.copy(valueoutput) #Copy output to clipboard
        print("Copied to clipboard!")
#

original

#

@rugged sparrow

rich hound
#

make this more cryptic?

#

!e

z = ", ".join(map(str, [_**2 for _ in range(10)]))
print(z)
night quarryBOT
#

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

0, 1, 4, 9, 16, 25, 36, 49, 64, 81
urban cradle
rich hound
#

exactly what i said

urban cradle
#

just change plain characters to chr(random equation with dumbass shir) and get rid of plain numbers and do some stuff

rich hound
#

i do that

#

but i want it literally unreadable

urban cradle
#

idk

#

code every variable in morse

#

create a new kind of encryption and encrypt all the variables & integers etc