#esoteric-python

1 messages Β· Page 45 of 1

versed eagle
#

oh discord fucked the indentation also lmao

unique heath
#

average discord

arctic skiff
#

oh thats what you meant

#

avg mobile user problems

versed eagle
#

the indentation is hopefully fixed now? i cant see it lmao

versed eagle
#

this has nothing to do with the user

#

its that mobile discord is bad

arctic skiff
#

I forgot to type "problems" in the end

versed eagle
#

lol

quartz wave
#

i love how my split tab is perfectly configured so that the braces align

earnest wing
#

i made python decorators more readable

long fulcrum
#

can this be golfed further?

import sys
for i in sys.argv[1:]:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))```
fleet bridge
long fulcrum
#

thats not what it does

#

!eval

yhyg=["each show say a too"]
for i in yhyg:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))```
night quarryBOT
fleet bridge
#
import sys
for i in sys.argv[1:]:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))
for i in sys.argv[1:]:s=i.split();print(*map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in map(list,s)])))
long fulcrum
#

thanks

fleet bridge
# long fulcrum thanks
import sys
for i in sys.argv[1:]:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))
for i in sys.argv[1:]:s=i.split();print(*map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in map(list,s)])))
for i in sys.argv[1:]:s=i.split();print(*(''.join(w[j]if j<len(w)else''for w in s)for j in range(max(map(len,s)))))
for i in sys.argv[1:]:s=i.split();print(*(''.join((w+'\0'*99)[j]for w in s)for j in range(max(map(len,s)))))
#

i guess \0 chars are filtered before sending them to stdout

long fulcrum
#

not for me

fleet bridge
#

what happens when you do print('a\0b') ?

fleet bridge
long fulcrum
stray grove
#

hello my fellow esoteric mfs OH MY GOD

#

BRO WTF

#

oh not that bad

fleet bridge
stray grove
#

i'm on linux

#

using the alacritty terminal

quartz wave
#

it's a b

quartz wave
fleet bridge
#

w[j:j+1]
^ that's a nice idea

hybrid trail
#

using zip I can get to 112 πŸ€”

quartz wave
#

oh

#

i got the 2nd place

#

wait a minute

#

nvm

hybrid trail
#

hmmmm

#

im stuck at 96

#

is the 89 similar to your solution above?

#

because my best solution so far is

quartz wave
#

what's yours

#

?

#

spoiler it

#

||my 89 uses the *99 trick||

#

oh.

#

the same thing i tried earlier :p

hybrid trail
#

yeah ||['']*99|| is smart I didn't think of that

quartz wave
#

oh-

quartz wave
#

it doesn't use the ||variable (un)packing trick!!||

hybrid trail
#

hmmmm

#

ill dm you

versed eagle
arctic skiff
unique heath
#

i'm traumatized

tranquil yarrow
arctic skiff
earnest wing
unique heath
#

more readable πŸ’€

arctic skiff
arctic skiff
restive void
arctic skiff
#

would love to see that

#

imagine saying "I code in decorators in python"

restive void
#

(I bet it isn't even a large change, she already has the "giant wall of @_._@_._-mess" to text converter.)

arctic skiff
#

rookie question but ```py
@a_dec@something

is same as

@a_dec
@something```right?

earnest wing
earnest wing
restive void
arctic skiff
#

I kinda forgot decorators

#

little

restive void
arctic skiff
#

ohh

#

ok

#

I remember now

#

matrix multiplication

earnest wing
restive void
#

I remember PEP-614, waited for it for a long time :D

#

Was so annoyed I couldn't do @lambda: ...

earnest wing
#

there's been a few really nice peps that just seem to drag on forever

#

typevar defaults was one

earnest wing
restive void
#

(or maybe it was "identity"? Don't remember)

earnest wing
#

shadowing builtin id

#

tbh i do that sometimes with the identity function

#

also, thank you for the feedback it's lovely to hear!

thin trout
#

Hey y'all

#

Remind me

#

How do you call code that basically repeats itself whenever you execute it

#

Like it starts something like XYZ, then it becomes XXYZZ, then XXXYZZZ

#

I don't think my explanations make any sense

#

Lmao

#

Maybe the actual rule is stricter than that

dreamy bridge
#

could this actually be golfed 164 chars?
https://open.kattis.com/problems/flagquiz?tab=metadata
my 176 chars (proudly in second place)

z,S=input,',';z()
p=[z().split(S)for i in S*int(z())]
s=[max(sum(x!=y for x,y in[*zip(i,j)])for j in p)for i in p]
print('\n'.join(S.join(i)for i,j in[*zip(p,s)]if j==min(s)))

(sort of) explained

z,S=input,',' # comma and input used more than 3 times
z() # read useless question line
p=[z().split(S) # 2d array of alternatives split by comma
   for i in S*int(z())] # iterate string * 2nd line of input num times
s=[max( # get incrogusity for each alternative - the maximum
    sum(x!=y for x,y in # num of "changes" to turn i to j
        [*zip(i,j)]) # loop and unpack i j like this
       for j in p)for i in p] # use nested loops
print('\n'.join( # print all alternatives
    S.join(i)for i,j in[*zip(p,s)]
                if j==min(s))) # with min incrogusity
versed eagle
#

same with ... for i,j in[*zip(p,s)] ...

dreamy bridge
#

oh yea zip is an iterator

#

what have i done

versed eagle
#

lol

dreamy bridge
#

welp thats 172

#

:)

versed eagle
#

i think its shorter to not use S for comma also

#

by 1 char

dreamy bridge
#

yes

#

omg

versed eagle
#

have you tried using itertools

#

i dont know if it'd be shorter here but itertools.product is cool

hybrid trail
dreamy bridge
dreamy bridge
versed eagle
#

its not shorter

dreamy bridge
#

oh nice free 2d array from whatever i give it

versed eagle
#

yeah

#

sadly all of the itertools stuff follows good naming conventions, so its too long for our purposes

hybrid trail
#

can you replace the final print with z? since input prints its first arg

hybrid trail
versed eagle
hybrid trail
#

163

z=input;z()
p=eval("z().split(','),"*int(z()))
s=[max(sum(x!=y for x,y in zip(i,j))for j in p)for i in p]
*map(print,(','.join(i)for i,j in zip(p,s)if j==min(s))),
floral meteor
#

the most useful python code: the machine that goes bing!

print('\7')
#

works best in a batch script or in the terminal

#

if you want your command line to ring a bell when it's done, simply append && py -c "print('\7')

#

c code with additional frowny faces!

dreamy bridge
#

just evalling a piece of code repetitively using string multiplication and i can just unpack things in thin air thanks to the last comma

#

this is next level golfing

quartz wave
#

142 ```py
for i,j in zip(p:=[x[:-1].split(',')for x in open(0)][2:],s:=[max(sum(map(str.ne,i,j))for j in p)for i in p]):j==min(s)!=print(*i,sep=',')

#

still don't know 164 though πŸ˜”
-# :3

dreamy bridge
#

HUH

#

OPEN(0) IS A THING

#

everyone golfing this to insanity

#

just realised i only know 1% of python so far

#

alr lemme try to comprehend these

quartz wave
#

so it turns out the newline exclusion isn't needed so

dreamy bridge
#

dont need [:-1]?

quartz wave
#

ya

#

!!

#

137

#
for i,j in zip(p:=[x.split(',')for x in open(0)][2:],s:=[max(sum(map(str.__ne__,i,j))for j in p)for i in p]):j==min(s)!=print(*i,sep=',')
dreamy bridge
#

somehow i already knew about walrus operators but i didnt know you could use it like that

#

didnt know != was called __ne__ as magic method as well

#

not sure how that j==min(s)!=print() works tho

quartz wave
#

short circuiting

dreamy bridge
#

it cuts off the expression when first expression is false?

#

damn thats genius

quartz wave
#

ya

#

same reason why x < y < z works in python

dreamy bridge
#

it does?

quartz wave
#

x < y < z -> (x < y) and (y < z)

dreamy bridge
#

i always used the latter

quartz wave
#

j==min(s)!=print() -> (j == min(s)) and (min(s) != print())

#

(all operands are evaluated only once and only if their part of the comparison is reached)

#

this seems lua golfable pithink

dreamy bridge
dreamy bridge
#

i used lua a few times but not for golfing

quartz wave
dreamy bridge
#

ohhh

quartz wave
dreamy bridge
#

oof

#

first glance lua just looked quite powerful for golfing with all those powerful string and table functions

#

then i realised i had to put end after my for loops

jolly rock
unique heath
floral meteor
#

see monty python "meaning of life" for why this is so important

#

as for why it must be evaluated in python, that is self explanatory

floral meteor
versed eagle
floral meteor
#

but that's implicit. Python coders don't like implicit

frigid nova
#

do you guys know what modulo is i am 14 so if anyone could explain it a bit simple

hybrid trail
#

Is there any way to shorten print(chr(F)+chr(I)*(F!=I)), where F and I are integers?

fleet bridge
#

print(("%c%c"%(F,I))[:1+(F!=I)])

#

no idea if it works or is shorter

hybrid trail
#

the brackets take precedence over % formatting

fleet bridge
#

I see, then I have to add another pair of parens

earnest wing
versed eagle
#

i stand corrected

quartz wave
#

print(chr(F)+chr(I)*(F!=I)) still is much shorter

versed eagle
hybrid trail
#

how does it even work?

versed eagle
#

"%c%%c"%F%I = f"{chr(F)}%c"%I

arctic skiff
arctic skiff
arctic skiff
#
>>> 3%2
1
>>> 5%2
1
>>> 4%2
0
>>> ```
#

this channel is about writing shortest possible or cursed code

unique heath
#
x = 3
y = 2

(x/y-int(x/y))*y```
quartz wave
gleaming linden
#

divmod(x,y)[1]

quartz wave
arctic skiff
#

also thats what elementary and high schools would teach

unique heath
#

elementary schoolers dont know what a modulus is

versed eagle
#

if you understand the one, the other follows trivially i think

#

hence why i linked the one

#

so the other could be understood

arctic skiff
quartz wave
#

also modulus != modulo

#

remainder is known from elementary but not modulo

arctic skiff
versed eagle
arctic skiff
#

I said thats what THEY teach

quartz wave
#

C teachers are gonna have an easy time explaining the % operator ^^

arctic skiff
#

those kids don't know what modulo is

arctic skiff
quartz wave
#

python teachers, on the other hand, with negative operands of %....

quartz wave
arctic skiff
#

ohh

versed eagle
#

\forall (a \in \mathbb{R}), (b \in \mathbb{R} \setminus {0})

#

where \mathbb{R} is not actually the set of all real numbers but rather all the numbers python is able to represent

versed eagle
quartz wave
versed eagle
#

remainder has the sign of the dividend

rain lichen
#
import itertools
thing = lambda string, num: [tup for index, tup in enumerate(list(itertools.product(string, repeat = num))) if index % 2 == 0]
print(thing("ABCD", 2))```
versed eagle
quartz wave
# long fulcrum how?

modulo has the sign of the divisor and is a result of floor division
remainder has the sign of the dividend and is a result of truncated division

#

!e ```py
x = -5
y = 2
print(x - int(x / y)*y) # remainder
print(x - x//y * y) # modulo [default]
print(x % y)

night quarryBOT
long fulcrum
#

can this be shorted ive been trying something like this

e=u[0];u=u[1:]+" "
e,*u=u=u[1:]+" "```
fleet bridge
#

~~```py
e,*u=u+" "

fleet bridge
#

~~```py
e,*_=u;u=u[1:]

versed eagle
fleet bridge
# versed eagle is u a string

my guess is this: ```py
u: str
e: str

before:

u = 'abc'

after

u = 'bc '
e = 'a'
``` so one character is "pulled" from u into e, and space is appended to u

fleet bridge
versed eagle
#

im wondering if u must be a string afterwards

#

or if its only accessed by indexing, etc

fleet bridge
#
e=u[0];u=u[1:]+" "
e,u=u[0],u[1:]+' '
unique heath
#

14 = 0 (mod 7)
18 = 4 (mod 7)
20 = 6 (mod 7)
-5 = 2 (mod 7)

#

remainders dont really

#

14 / 7 = 2r0
18 / 7 = 2r4
20 / 7 = 2r6
-5 / 7 = 0r-5

versed eagle
unique heath
#

well

#

kinda

#

wraps around both ways ig is the better way to say it

versed eagle
unique heath
versed eagle
#

well yes

unique heath
#

remainders dont really do that

versed eagle
unique heath
versed eagle
unique heath
#

n-1*

#

i have no clue what im talking about

#

remainder of -6 divided by 5 isnt 4

#

ig

versed eagle
#

r(a, b) = a - s(a) |b| ⌊|a/b|βŒ‹
m(a, b) = a - b⌊a/bβŒ‹

#

(unless im misremembering!)

rain lichen
#
divisible_by = lambda self, arrayOfThingsToDivideBy, arrayOfNumbers : [num for num in arrayOfNumbers if any(num % divisor == 0 for divisor in arrayOfThingsToDivideBy)]```
unique heath
#

we need to golf this

unique heath
rain lichen
fleet lintel
#

Remainders are weird when not precisely defined. For the remainder of x / y, I think it's reasonable to say -y < remainder < y, but that gives two potential solutions for every division, one negative and one positive, ie -6 / 5 = -1 * 5 + -1 = -2 * 5 + 4. Modulo is a convenient way of picking one, it's always the positive one. math.remainder restricts the bounds on remainder so that there is only ever one solution. I suppose the remainder that was being confused over is choosing the remainder that matches the sign of x, besides 0 which is always positive?

unique heath
#

yeah

rain lichen
# unique heath yeah
# sdf 23 safs8 5 sdfsd8 sdfs 56 21sfs 20 5 --> [56, 23, 20, 5, 5]
get_array_of_numbers = lambda self, string : sorted([int(num) for num in string.split() if num.isdigit()], reverse=True)
versed eagle
#

under the flooring definition of modulo anyway

ancient lagoon
#

What's Esoteric Python

rain lichen
#

what is the difference between writing esoteric code, and writing obfuscated code?

rain lichen
karmic pumice
#

im not sure. i guess esoteric code usually involves doing something in an unusual way, like, an interesting but cursed solution to a problem perhaps, while the goal of obfuscation is just to make the code hard to read / analyze

rain lichen
cyan root
#

Need a help in half string.. with times..

clear venture
sick reef
#

!e

_=((()==())+(()==()));__=(((_<<_)<<_)*_);c_matrix=('c%'[::(([]!=[])-(()==()))])*((_<<_)+(_*_))%((__+((_<<_)+(()==()))),((_<<_)<<_),(__+((_<<_)+(_*_))),(__+(((_<<_)<<_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)<<_)+(((_<<_)*_)+((_*_)+_)))),(__+(((_<<_)<<_)+((_*_)+(()==())))),((_<<_)<<_),(__+((_<<_)*_)),(__+(((_<<_)<<_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)<<_)+((_<<_)+(_*_)))),(__+(((_<<_)<<_)+(()==()))),(__+(((_<<_)<<_)+(((_<<_)*_)+_))))
exec("print(c_matrix)", dict().setdefault(c_matrix))
night quarryBOT
sick reef
#

Supposed to be "Polar Bears". thonk

lilac breach
arctic elm
grave grail
fleet bridge
#

@karmic pumice ```py

"""
x // f
f @ x
(f @ g) @ x

~(1,2) // print
~{'sep':','} & ~(1,2,3) // print # 1,2,3
"""

import fishhook
import functools

class UnpackedArgs:
def init(self, args=(), kwargs={}):
self.args = args
self.kwargs = kwargs

def __repr__(self) -> str:
    parts = []
    parts.extend(map(repr, self.args))
    parts.extend(f'{k!s}={v!r}' for k, v in self.kwargs.items())
    args = ', '.join(parts)
    return f'<{args}>'

def __and__(a: UnpackedArgs, b: UnpackedArgs) -> UnpackedArgs:
    if not isinstance(b, UnpackedArgs):
        return NotImplemented
    return UnpackedArgs(a.args + b.args, a.kwargs | b.kwargs)

def call(c, args):
if not isinstance(args, UnpackedArgs):
return c(args)
return c(*args.args, **args.kwargs)

@fishhook.hook(tuple)
def invert(self: tuple, /) -> UnpackedArgs:
return UnpackedArgs(args=self)

@fishhook.hook(dict)
def invert(self: dict, /) -> UnpackedArgs:
return UnpackedArgs(kwargs=self)

@fishhook.hook(object)
def matmul(a: object, b: object, /) -> object:
if not callable(a):
return NotImplemented
if not callable(b):
return call(a, b)

@functools.wraps(b)
def f(*args, **kwargs):
    return a(b(*args, **kwargs))

return f

@fishhook.hook(object)
def rfloordiv(a: object, b: object, /) -> object:
if not callable(a):
return NotImplemented

return call(a, b)
ruby raft
#

yo

#

idk any other channel that could fit this problem so i just chose this one

#
from __future__ import annotations

import typing as t

from dataclasses import dataclass

T = t.TypeVar("T")
ObjectT = t.TypeVar("ObjectT")
ObserverT = t.Callable[[T], None]

class ReactiveField(t.Generic[T]):
    __slots__: t.Sequence[str] = ("_value", "_observers")

    def __init__(self, value: T) -> None:
        self._value = value
        self._observers: list[ObserverT] = []

    @t.overload
    def __get__(self, obj: None, otype: type[ObjectT]) -> ReactiveField[T]:
        ...

    @t.overload
    def __get__(self, obj: ObjectT, otype: type[ObjectT]) -> T:
        ...

    def __get__(self, obj: t.Optional[ObjectT], otype: t.Optional[type[ObjectT]]) -> t.Union[T, ReactiveField[T]]:
        if obj is None and hasattr(otype,  "__dataclass_fields__") is True: 
            return self
        
        return self._value
    
    def add_observer(self, callback: ObserverT) -> None:
        self._observers.append(callback)
    
    def __set__(self, obj: ObjectT, value: T) -> None:
        self._value = value

        for observer in self._observers:
            observer(self._value)

@dataclass
class Config:
    age: ReactiveField[int] = ReactiveField(1)

config = Config()

callback = lambda hello: print(f"changed to {hello}")

Config.age.add_observer(callback)
print(config.age) # 1
config.age = 5 # changed to 5```
#

Im trying to create "reactive fields", fields that you can add observers to that are called when the field value changes

#

Now I got this working which is used with dataclasses.dataclass and its pretty cursed + observers are not actually bound to the instance

#

Is there a way I could change this so observers only observe a field in one instance? Preferably with a similar syntax?

karmic pumice
#

cant you just use dataclasses.field(default_factory = lambda: ReactiveField(1))

#

also on what version is this supposed to work because the typehints are deprecated

ruby raft
#

3.9.13 works fine

karmic pumice
#

typing.Sequence[] is deprecated as of 3.9 no? you're supposed to use it from collections.abc now

ruby raft
karmic pumice
#

it would be created on each instance, and descriptors already work on instances. for adding a callback to a specific instance you could make some function i guess, to not invoke the __get__

ruby raft
#

well that would override the descriptor in a way, if you did print(config.age) it would print the ReactiveField object

#

what I thought about is, specifying the instance as parameter in the add_observer method

#

the problem is, I would have to store the observer functions in a dict, the key being the instance and the value being the list of callbacks for that instance

karmic pumice
#

no you can use inspect.getattr_static to get the actual descriptor on the instance without invoking its get

ruby raft
#

lemme see

#

hm ok not sure Im a fan of having to specify the attribute as a string tho, not as user friendly as the dot notation

karmic pumice
#

fair

ruby raft
#

as in ```py
class ReactiveField(t.Generic[T]):
slots: t.Sequence[str] = ("_value", "_observers")

def __init__(self, value: T) -> None:
    self._value = value
    self._observers: dict[ObjectT, list[ObserverT]] = {}

@t.overload
def __get__(self, obj: None, otype: type[ObjectT]) -> ReactiveField[T]:
    ...

@t.overload
def __get__(self, obj: ObjectT, otype: type[ObjectT]) -> T:
    ...

def __get__(self, obj: t.Optional[ObjectT], otype: t.Optional[type[ObjectT]]) -> t.Union[T, ReactiveField[T]]:
    if obj is None and hasattr(otype,  "__dataclass_fields__") is True: 
        return self
    
    return self._value

def add_observer(self, obj: ObjectT, callback: ObserverT) -> None:
    if obj not in self._observers.keys(): 
        self._observers[obj] = []

    self._observers[obj].append(callback)

def __set__(self, obj: ObjectT, value: T) -> None:
    self._value = value

    for observer in self._observers.get(obj, ()):
        observer(self._value)

@dataclass
class Config:
age: ReactiveField[int] = ReactiveField(1)

def __hash__(self) -> int:
    return id(self)```
#

Adding observers as follows:

config = Config()
Config.age.add_observer(config, callback)```
karmic pumice
#

might've just made the most cursed thing i did

#

!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.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

karmic pumice
ruby raft
#

What the hell

#

Very impressive

scarlet bone
#

old

#

ola

real geyser
#

e

scarlet bone
#

bro

#

i did the alt

real geyser
#

i saw it

scarlet bone
#

u know when u do alt

#

and u press random sh

#

u get a letter or

#

a character

#

now hange that +1 at the end to 31

#

huh

#

!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +1))

night quarryBOT
scarlet bone
#

!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +31))

night quarryBOT
scarlet bone
#

loL

pure vapor
#

Is there a point in doing any of that? Since its so unreadable and doubt anyone wants to touch and maintain it

real geyser
#

!e !e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +33))

real geyser
#

!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +33))

scarlet bone
#

like it would be awesome

night quarryBOT
scarlet bone
#

it would be awesome if someone did as a challange

real geyser
#

!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +64))

night quarryBOT
scarlet bone
#

and everyone in the world particiapted on it

real geyser
#

J

scarlet bone
#

wathc

#

!e print(chr((int('0b0001', 2) * int('0x1', 16) + int('0o0', 8) + len('') + (int('0x1', 16) - int('0b0', 2)) + int('1') - int('0') + int('0o1', 8) - int('0b0', 2) + len('a') - len('b') + (int('0x1', 16) + int('0b0', 2) - int('0')) * (1) - int('0x0', 16) + len('') + (int('0b1', 2) * int('0x1', 16) - int('0x0', 16) + (len('') + 1 - len('') + int('0o1', 8) - int('0b0', 2) + (int('0x1', 16) - int('0o0', 8)) - len('') + (int('0b1', 2) - int('0')) + len('a') - len('b') - (int('0x0', 16) + int('0b0', 2) - len('') + (0))) - (int('0b1', 2) + int('0x0', 16) - len('') + int('0o1', 8) - len('') + len('a') - len('b') + int('1') - int('0') + int('0x1', 16) - int('0b0', 2) + len('') - (int('0o1', 8) + len('') - len('b') + int('0x0', 16) - int('0b0', 2)) - len('') + int('0o1', 8) - int('0b0', 2) + int('0x1', 16) - len('') + int('0b1', 2) - int('0x0', 16) + len('a') - len('b') + (int('0b1', 2) * int('0x1', 16) - len('') + (int('0x1', 16) - int('0b0', 2))) - (int('0b0', 2) + len('') - int('0o1', 8) + int('0x1', 16) - int('0b0', 2))) % 31))))

night quarryBOT
scarlet bone
#

bum

real geyser
#

!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +3))

night quarryBOT
real geyser
#

!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +50))

night quarryBOT
scarlet bone
#

do this '

#

u can crash bot

#

if u do three '''

real geyser
#

!e '''

scarlet bone
#

and end with three

real geyser
#

!e ''''''

scarlet bone
#

!e print("''' '''")

night quarryBOT
real geyser
#

!e print("''' '''")

scarlet bone
#

no u have to do with functions

#

lie switch

#

not switch

#

but change a letter to '

real geyser
#

!e print("''''''''''''''''''''''''''''''''''''''''' '''")

night quarryBOT
scarlet bone
#

!e print("''' print("helloworld") '''")

night quarryBOT
# scarlet bone !e print("''' print("helloworld") '''")

:x: Your 3.12 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     print("''' print("helloworld") '''")
003 |           ^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
#

:x: Your 3.12 eval job has completed with return code 1.

001 |   File "/home/main.py", line 5
002 |     )
003 |     ^
004 | SyntaxError: unmatched ')'
real geyser
#

!e def moo():
big_list = []
while True:
big_list.append('x' * 10**6) # Keep adding large strings to the list

scarlet bone
#

.replace

#

use that

#

!e print("Heee print("Helloworld") eee LLO ")

night quarryBOT
scarlet bone
#

fk

#

!e a = "333 , 333"
print(a.replace(3,"'"))

night quarryBOT
# scarlet bone !e a = "333 , 333" print(a.replace(3,"'"))

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     print(a.replace(3,"'"))
004 |           ^^^^^^^^^^^^^^^^
005 | TypeError: replace() argument 1 must be str, not int
real geyser
#

!e !e print("Heee print("Helloworld") eee LLO ")

night quarryBOT
scarlet bone
#

xd

real geyser
#

!e print("Heee print(\"Helloworld\") eee LLO ")

night quarryBOT
scarlet bone
#

!e a = "333 , 333"
print(a.replace("3","'"))

night quarryBOT
pure vapor
#

Why not make art?

#

!e

print('\n'.join([ (11-x)*' '+ ''.join(['* ' for _ in range(x)]) for x in range(1,11, 2)]))

Like this for example

night quarryBOT
real geyser
scarlet bone
#

!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print(a.replace(3,"'"))

night quarryBOT
scarlet bone
#

!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print(a.replace("3","'"))

night quarryBOT
scarlet bone
#

hmm i found before a way to change it

real geyser
#

!e print('x'**434444)

night quarryBOT
# real geyser !e print('x'**434444)

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print('x'**434444)
004 |           ~~~^^~~~~~~
005 | TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
real geyser
#

!e print('x*2'**434444)

night quarryBOT
# real geyser !e print('x*2'**434444)

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print('x*2'**434444)
004 |           ~~~~~^^~~~~~~
005 | TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
real geyser
#

!e print('x'*2**434444)

night quarryBOT
# real geyser !e print('x'*2**434444)

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print('x'*2**434444)
004 |           ~~~^~~~~~~~~~
005 | OverflowError: cannot fit 'int' into an index-sized integer
scarlet bone
#

!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","'"))

night quarryBOT
scarlet bone
#

!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","'''"))

night quarryBOT
scarlet bone
#

!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","''''"), "\n")

real geyser
#

!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","''"'"))

night quarryBOT
scarlet bone
#

it needed to be like im doing smth like that

#

ye

#

then u could get out of this black box

real geyser
#

!e import os
os._exit(1)

night quarryBOT
scarlet bone
#

llol

real geyser
#

oh the black box?

scarlet bone
#

!e import subprocess
subprocess.run([[pip],[uninstall],[pip]],shell=True)

night quarryBOT
pure vapor
#

!e

import random, string
print("".join([random.choice(string.ascii_letters + string.digits) for i in range(8)]))

Random password for this second

real geyser
#

!e ```
print('```')

night quarryBOT
# real geyser !e ``` print('\`\`\`') ```

:white_check_mark: Your 3.12 eval job has completed with return code 0.

001 | /home/main.py:1: SyntaxWarning: invalid escape sequence '\`'
002 |   print('\`\`\`')
003 | \`\`\`
scarlet bone
#

!e import subprocess
subprocess.run(['pip', 'uninstall', '-y', 'pip'], check=True)

night quarryBOT
# scarlet bone !e import subprocess subprocess.run(['pip', 'uninstall', '-y', 'pip'], check=Tru...

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     subprocess.run(['pip', 'uninstall', '-y', 'pip'], check=True)
004 |   File "/lang/python/default/lib/python3.12/subprocess.py", line 548, in run
005 |     with Popen(*popenargs, **kwargs) as process:
006 |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
007 |   File "/lang/python/default/lib/python3.12/subprocess.py", line 1026, in __init__
008 |     self._execute_child(args, executable, preexec_fn, close_fds,
009 |   File "/lang/python/default/lib/python3.12/subprocess.py", line 1953, in _execute_child
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/U6RN3MVSPRMT3HOSIB4WXWXRZA

night quarryBOT
scarlet bone
real geyser
#

!e `
print('```')

`

`

night quarryBOT
# real geyser !e ` print('```') ` ` ```1

:x: Your 3.12 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     print('
003 |           ^
004 | SyntaxError: unterminated string literal (detected at line 1)
scarlet bone
#

damn

real geyser
#

!e `
print('```')

night quarryBOT
# real geyser !e ` print('```') ``` ```

:x: Your 3.12 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     print('
003 |           ^
004 | SyntaxError: unterminated string literal (detected at line 1)
scarlet bone
#

'''
!e print("Hello world")
'''

#

!e print("Hello world")
a = "'''"
print("what")
b="'''"

night quarryBOT
#

:white_check_mark: Your 3.12 eval job has completed with return code 0.

b'`'
scarlet bone
#

!e ```print("Hello world"); a ="'''"'''

'''
'''
'''
'''
'''`

night quarryBOT
scarlet bone
#

''' a '''

#

!e
a= "" b = ""
print (a,b)

night quarryBOT
scarlet bone
#

:v

#

!e a=""
print("Hello world"

night quarryBOT
scarlet bone
#

xddddddd

real geyser
#

WHAT

scarlet bone
#

hahahahaha

#

!e text = "He said, "Hello, world!""
print(text)

night quarryBOT
scarlet bone
#

lol

night quarryBOT
#

:white_check_mark: Your 3.12 eval job has completed with return code 0.

001 | Byte representation of the backtick character:
002 | \x60
scarlet bone
#

!e ```
a= "333,333"
print(a.replace("3","`"))

night quarryBOT
scarlet bone
#

and bum

#

hehahahahat

#

they fixed it

real geyser
#

!e ```
a = "333"
print(a.replace("3","`"))

night quarryBOT
real geyser
#

so how do we break it

#

if only we can assign `...

scarlet bone
#

we hack discord of the admin then we go remove the line of code they just fixed

#

!e

real geyser
#

!e`

night quarryBOT
#
Did you mean...

Β» equals-true
Β» empty-json
Β» exit()
Β» environments
Β» envs
Β» except
Β» on-message-event
Β» for-else
Β» enumerate

real geyser
#

!e eval("pip uninstall")

night quarryBOT
# real geyser !e eval("pip uninstall")

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     eval("pip uninstall")
004 |   File "<string>", line 1
005 |     pip uninstall
006 |         ^^^^^^^^^
007 | SyntaxError: invalid syntax
scarlet bone
#

!e a=5 print(a)

night quarryBOT
scarlet bone
#

!e a="333,333,444,555,333,444" print(a.replace("4","``````"))

real geyser
#

!e py user_input = "__import__('os').system('rm -rf /')" eval(user_input)

night quarryBOT
night quarryBOT
scarlet bone
#

!e a="333,333,444,555,333,444" print(a.replace("4","``````"))

night quarryBOT
scarlet bone
#

error

#

there is no error here

#

but it gives error :v

#

new hack

#

!e a="333,333,444,555,333,444" print(a.replace("4","``````"))

night quarryBOT
scarlet bone
#

!e a="333,333,444,555,333,444" print(a.replace("4","``````"))

night quarryBOT
real geyser
#

we should try something else

scarlet bone
#

!e a="333,333,444,555,333,444" print(a.replace("4",""))
``
`

print("Test")
night quarryBOT
real geyser
#

what to do tho

scarlet bone
#

its givin errors

#

~t~

#

is there other

#

like `

#

or


#

tf

real geyser
#
===
]]]
~~~
'''
,,,



\\\
scarlet bone
#

=== test===

#

nope

#

]]] test ]]]

real geyser
#

~ this

scarlet bone
#

oh

real geyser
#

back

#

--back--

#

#= n

#

#- mo

#

-# mo

scarlet bone
#

!e a="333 OMG WRONG ANSER 333"
print(a.replace("3", "~"))

night quarryBOT
scarlet bone
#

capuchino

#

!e a="333 OMG WRONG ANSER 333" print(a.replace("3", "~"))

real geyser
night quarryBOT
scarlet bone
#

two on other side

#

three

real geyser
scarlet bone
#

~~~a ~~~

real geyser
#

Hi

scarlet bone
#

no two

#

~~OLAMIGUSTA``

#

f

#

imam go now

real geyser
#

ouch

scarlet bone
#

just one test

real geyser
#

oucch

#

o

scarlet bone
#

iii T iii

#

:v

real geyser
#

YAAAAAAAAAAAAa

scarlet bone
#

[[[ A ]]]

#

gimem how

#

big text?

real geyser
#

start wit hashtag

#

and space

#

moo

#

# <text>

scarlet bone
#

how

#

test

#

oj

#

!e a = "333,444,555,666,111,333,111,555,666,444" print(a.replace("3","~")) print(a.replace("4",""))
print(a.replace("5","#"))

night quarryBOT
scarlet bone
#

!e a = "333,444,555,666,111,333,111,555,666,444" print(a.replace("3","~")) print(a.replace("4","")) print(a.replace("5","#"))

night quarryBOT
scarlet bone
#

!e ```
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))

print(''.join(part.replace('4', '') for part in a.split(',')))

print(''.join(part.replace('5', '#') for part in a.split(',')))

night quarryBOT
scarlet bone
#

!e `
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))

print(''.join(part.replace('4', '') for part in a.split(',')))

print(''.join(part.replace('5', '#') for part in a.split(',')))
`

night quarryBOT
scarlet bone
#

!e ```
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))

print(''.join(part.replace('4', ''') for part in a.split(',')))

print(''.join(part.replace('5', '#') for part in a.split(',')))

night quarryBOT
scarlet bone
#

!e ```
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))

print(''.join(part.replace('4', "'") for part in a.split(',')))

print(''.join(part.replace('5', '#') for part in a.split(',')))

night quarryBOT
scarlet bone
#

!e ``
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))

print(''.join(part.replace('4', '') for part in a.split(',')))

print(''.join(part.replace('5', '#') for part in a.split(',')))
``

night quarryBOT
scarlet bone
#

fk it

real geyser
#

!e ```py
import random

def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
else:
image += '. '
image += '\n'
return image

print(make_image(10,10))

night quarryBOT
real geyser
#

image maker

#

!e ```py
import random

def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
else:
image += '. '
image += '\n'
return image

print(make_image(10,10))

night quarryBOT
real geyser
#

!e``` import random

def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
elif Chance(8):
image += '$ '
elif Chance(16):
image += '^ '
elif Chance(32):
image += '~ '
elif Chance(64):
image += '# '
elif Chance(128):
image += '& '
elif Chance(256):
image += '{ '
elif Chance(512):
image += '} '
elif Chance(1028):
image += '! '
elif Chance(2048):
image += '\ '
else:
image += '. '
image += '\n'
return image

print(make_image(10,10))```

night quarryBOT
real geyser
#

!e ```py
import random

def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
elif Chance(8):
image += '$ '
elif Chance(16):
image += '^ '
elif Chance(32):
image += '~ '
elif Chance(64):
image += '# '
elif Chance(128):
image += '& '
elif Chance(256):
image += '{ '
elif Chance(512):
image += '} '
elif Chance(1028):
image += '! '
elif Chance(2048):
image += '\ '
else:
image += '. '
image += '\n'
return image

print(make_image(10,10))```

night quarryBOT
hybrid trail
#

Can something like (condition and value or"") be golfed further? (where condition is a bool and value is a string).

I would love to do value*condition but I need value to be evaluated lazily

night quarryBOT
#

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     exec("".join(map(chr,[72,101,108,108,111,32,87,111,114,108,100,33])))
004 |   File "<string>", line 1
005 |     Hello World!
006 |           ^^^^^
007 | SyntaxError: invalid syntax
long fulcrum
craggy hamlet
#

what on earth happened above us

#

people trying to escape the bot? lol

marble spade
#

yeah

unique heath
craggy hamlet
#

It was a sad attempt at a sandbox escape

bright valve
#

if someone manages to escape it does it get banned or smt?

arctic skiff
grave grail
late skiff
#

hello! nice to meet you !

#

I am proficient to python.

#

I want to discuss with here!

grave grail
unique heath
#

thats over in #bot-commands

green folio
#

!e a = 333444555666777888999000111222 print(f'{a:,}')

night quarryBOT
green folio
#

!e i = 1 while True: print(f'{i:,}') i += 1

night quarryBOT
green folio
#

!e i = 1 while True: print(f'{i:,}') i += i

night quarryBOT
fleet bridge
green folio
#

oh

grave grail
#

lul

#

There's just flood with people just running eval in this channel

#

I get it, eval = evil and esoteric is evil, but don't come here unless you have a esoteric intend:)

unique heath
#

!py

night quarryBOT
#
System Python

Why Avoid System Python for Development on Unix-like Systems:

  • Critical Operating System Dependencies: Altering the system Python installation may harm internal operating system dependencies.
  • Stability and Security Concerns: System interpreters lag behind current releases, lacking the latest features and security patches.
  • Limited Package Control: External package management restricts control over versions, leading to compatibility issues with outdated packages.

Recommended Approach:

  • Install Independent Interpreter: Install Python from source or utilize a virtual environment for flexibility and control.
  • Utilize Pyenv or Similar Tools: Manage multiple Python versions and create isolated development environments for smoother workflows.
unique heath
#

oop

#

!eval py print("hello world")

night quarryBOT
unique heath
#

this is esoteric because no one expects anyone who knows what esopy is to run a normal hello world in the esopy channel

austere mauve
#

Ever heard of people complaining that python doesn't have multi line comments? We have them... and much more. We have a lot of ways for creating comments, here are some of them in a comprehensive python Hello World! program. Why no one uses them?

#

!e ```py
"a simple 'Hello World!' program in python"

@(lambda x: x or "this is a function declaration, you can call it later")
def hello():
print("Hello", "World!", end="\n", sep=" ")
"""
Where arguments are:
"""
1; "Hello" # first value
2; "World!" # second value, will be glued to the first value
3; end="\n" # ending for the text, it is appended at the and of the final string
4; sep=" " # when joining multiple values for printing, this will be inserted in between them, so in this case:
"Hello" + " " + "World!" + "\n"; "will be done"

f"And here's how you call a function: { hello() }"

if not ...:
"required" not in "credits"
license = None

0\
   /0x0\
            <3
night quarryBOT
unique heath
#

/0x0\

unique heath
sick hound
#

also isnt having an eval command on a public bot kinda risky?

#

like couldnt someone just eval this

import os
os.system("sudo rm -rf /")
jolly rock
sick hound
jolly rock
#

if you find any vulnerability, just make sure to report it to the staff o7

sick hound
#

k

#

does it work in dms?

jolly rock
sick hound
#

if i do find a vulnerability then it wouldnt be very nice to discover it in a public channel

fleet bridge
grave grail
#

so you couldn't download the transaction data/upload your result anyway

grave grail
#

and remember to follow the security policy of the repository if you find a vulnerability

fleet bridge
grave grail
#

do you not have to constantly updating the data in real time?

#

or how certain amount of time delay is allowed

grave grail
fleet bridge
#

good golfing exercise :)

grave grail
#

(I don't even know how the formatting and stuff work lmao

#

maybe we could test the hash rate of the eval command

#

!e

import hashlib, time

start = time.perf_counter()
hash_count = 0
PRE_CHECK = 200000
while True:
    for i in range(PRE_CHECK):
        hashlib.sha256(b"a").hexdigest()
    hash_count += PRE_CHECK
    print(f'{hash_count/(time.perf_counter()-start)}')
night quarryBOT
# grave grail !e ```py import hashlib, time start = time.perf_counter() hash_count = 0 PRE_CH...

:x: Your 3.12 eval job timed out or ran out of memory.

001 | 1733476.270807509
002 | 1735724.3620274302
003 | 1759635.260845237
004 | 1774141.9768671254
005 | 1769302.253515442
006 | 1769625.5134471557
007 | 1772058.161462909
008 | 1779751.23899121
009 | 1780753.8825872606
010 | 1783501.2218866139
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/ODD6W272DM3UOLQKRC323ZEIQU

grave grail
#

about 1800000 hash/s

#

I don't think it have any value

#

lul

#

consider an rtx 4090 have hash rate of 21975.5 MH/s

fleet bridge
#

it is python, reaching a million of something per second is challenging

grave grail
#

well, just a fu fact that it is zero value so you shouldn't even try

#

not get start with the input and output

#

the technically diffculty doesn't worth the value it could provide

#

(also this show it is a fairly powerful machine because my raspberry pi can only run 1000000 hash/s

fleet bridge
#

what can you on your PC achieve?

#

pasted the code here https://www.online-python.com/ and got 400k/s

grave grail
#

But I think MacBook would be lower since it run more random stuff

unique heath
#

i get 1.05 million/s

grave grail
#

also relatable how my macbook is 9y old and my raspberry pi is 5gen

unique heath
#

πŸ’€

#

my macbook is 6y and 4b pi

versed eagle
#

i get β‰ˆ 1,900,000 hashes/s with python 3.9.16

#

and β‰ˆ 1,650,000 hashes/s with both python 3.11.9 and python 3.12.5

#

interesting

#

performance degradations...

clear venture
#

Can't win all the micro benchmarks 😭

versed eagle
#

its probably a lot better with 3.13

#

since doing the same thing in a loop a bunch of times is like perfect for jit lol

clear venture
#

Truee

#

We're getting a real jit in 3.13?

versed eagle
#

yeag

#

llvm and all that

unique heath
#

w

stuck thorn
#

!e

import base64
def f23033123(code:str)->None:
    codes=code.split()
    pri=False
    for i in codes:
        fij389=""
        fij389 = "fdasfadsfasafdsadfsadfs" if base64.b64encode(i.encode()).decode()=='fDMxOCdGZGk=' else fij389
        if fij389:
            pri=True
        if fij389: continue
        if not pri: continue
        if i!=":3": continue
        j01238fjdojdao123=print
        j01238fjdojdao123(base64.b64decode("SGVsbG8gV29ybGQh").decode())
f23033123("|318'Fdi :3")
night quarryBOT
grave grail
grave grail
#

(would have been easier if you put break after printing

silk warren
#

what is a good practice to create a frozenset with 1 element

versed eagle
#

frozenset((element,)) works fine i would imagine

silk warren
versed eagle
#

frozenset({element}) might be clearer but it will be ever so slightly slower also

#

so i wouldnt in a tight loop

silk warren
#

i think i prefer the tuple option]

spice umbra
#

!e

def foo(val: int):
    def next():
        nonlocal val
        val += 1
    def actual() -> int:
        nonlocal val
        return val
    return next, actual
plus_one, current = foo(0)
print(current())
plus_one()
print(current())
night quarryBOT
fleet bridge
#

that is on-topic, imo

grave grail
#

How is that eso tho πŸ’€

restive void
grave grail
#

Ok, maybe I am weird but I don't think that's weird πŸ’€

restive void
#

Or wait, maybe you do?

grave grail
#

You don't

#

Only in next because it changed the variable

stuck thorn
#

!e

a=5
o="+"
b=5
def calc(a,b,o):
    import os,sys,time
    if o not in ['+','-',':','x','^']:return
    ex="{0}{1}{2}".format("{}".format(a),o,"{}".format(b)).replace(':','/').replace('x','*').replace('^','**')
    for i in "{}".format(a):
        if i.isdigit():continue
        return
    for i in "{}".format(b):
        if i.isdigit():continue
        return    
    if o=="/" and b==0:raise ZeroDivisionError
    with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
    os.system("{0} {1}".format(sys.executable,"{}\\exec.py".format(os.getcwd())))
    with open("{}\\result".format(os.getcwd()),"r") as file:r=file.read()
    os.remove("{}\\result".format(os.getcwd()))
    return r
print(calc(a,b,o))
night quarryBOT
# stuck thorn !e ```py a=5 o="+" b=5 def calc(a,b,o): import os,sys,time if o not in [...

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 20, in <module>
003 |     print(calc(a,b,o))
004 |           ^^^^^^^^^^^
005 |   File "/home/main.py", line 15, in calc
006 |     with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
007 |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
008 | OSError: [Errno 30] Read-only file system: '/home\\exec.py'
clear venture
#

tell me you use windows without telling me you use windows dead

grave grail
#

lul

median cloak
#

!epy import os; os.mknod("newfile.txt")

night quarryBOT
median cloak
#

!e
import os; os.mknod("newfile.ktx")

night quarryBOT
median cloak
#

!e
import os; os.mknod("newfile.lbx")

night quarryBOT
hybrid trail
#

Found on another server: how to reverse a list in python

l = [2, 9, 5, 1, 4, 1, 3]
from uu import*
Error.__lt__=DeprecationWarning
l.sort(key=Error)
print(l)
hybrid trail
#

Also code golfing challenge: write the shortest code which defines a function that returns that returns the first (the most significant) digit of the given number in base 10. (So if given 789, it should return 7)

grave grail
hybrid trail
grave grail
#

do you have to handle negative?

hybrid trail
#

no

grave grail
#

would you mind showing answer in spoiler

hybrid trail
#

I can't just reveal an answer immediately, that would ruin the fun :)

grave grail
#

I mean in spoiler, so people can see if they don't want to play, and just not open if they want to

versed eagle
hybrid trail
#

yes

versed eagle
versed eagle
#

wait

#

OH i think i got it

#

||```py
"{0!s:.1}".format

#

actually that depends on what you mean by "define a function"

#

but its a neat trick lol

hybrid trail
#

there's something even better

versed eagle
#

hm

hybrid trail
#

you've found like 2/3 of the tricks

versed eagle
#

||```py
"%.1s".mod

#

@hybrid trail is that it

#

or is there shorter

hybrid trail
#

yep

versed eagle
#

nice

hybrid trail
#

thats my solution

versed eagle
#

fun lil challenge

hybrid trail
#

very weird that a "precision" parameter would affect a string

#

esoteric, even

versed eagle
grave grail
#

That's not defining a function πŸ’€

fleet bridge
stuck thorn
grave grail
simple sphinx
#

hi hi, need some help with making a slight pooppost.
I like the dad joke "to be frank.... id have to change my name"
so I wanted to do a function that takes an object and returns an exact copy with an additional class called frank added to it
here is my code so far:

class a:
    pass
class b(a):
    pass

def create_frank(class_list):
    class frank: pass
    frank.__bases__ = class_list
    return frank

def be_frank(inp):
    ret = create_frank(inp.__class__.__bases__)
    for i in dir(inp):
        print(i)
        try:
            setattr(ret, i, getattr(inp, i))
        except:
            print("failed", i)
    return ret

print(be_frank(b()))

but im getting a weird error about some deallocator issue, can someone help?

unique heath
#

😭

#

truly a post of all time

quartz wave
night quarryBOT
quartz wave
#

although i don't think you should be returning a class from passing an instance-

simple sphinx
#

oops, meant to add parans, after the call of create frank

unique heath
#

people named frank:

silk warren
#

thought i'd also post it here

#

since it fits i guess

versed eagle
#

what definition would you use

#

since you didnt give the function a name either lol

grave grail
#

creation of a function

#

with lambda/def syntax

versed eagle
#

a new callable object was generated

#

bound method :3

hybrid trail
#

I'm pretty sure codegolf stack exchange allows methods

#

as standalone submissions

versed eagle
#

cant do it as an expression because you're allowing def

#

and you didnt assign the lambda a name

grave grail
#

(define a function
never said it have to be used as long as it is valid

#

and you said define so I think it must have to use lambda/def

#

(unless my defintion of define a function is wrong, if so, please correct me

versed eagle
#

normally it means 'create and give a name'

#

but you didnt give yours a name so i followed your usage

#

Β―_(ツ)_/Β―

grave grail
#

well for me, that should more like get a callable than defining it

#

(don't need name, who cares name lul

versed eagle
#

unless you're calling it in in the same expression that generates it

#

which you cant do with def

versed eagle
grave grail
#

Well, because from definition, only those 2 can be considered as define (I am not saying I am correct)

median cloak
#

!e

from functools import reduce; from operator import or_ ;from itertools import starmap; this = that = or_func = something_else = lambda: True
print('hi ppl (:' * int(reduce(or_,
starmap(lambda lol2, more_lol: lol2 and more_lol, # yes i purpusfully put DoYouThinkThisCodeIsNice like that 😎😎😈😈
            zip([this(), that(), or_func(), something_else()], [that(), or_func(), something_else(), this()])
    ))) if any([that(), or_func(), something_else(), this()]) else '')```
night quarryBOT
night quarryBOT
#

:incoming_envelope: :ok_hand: applied timeout to @sick hound until <t:1723681699:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).

The <@&831776746206265384> have been alerted for review.

topaz sphinx
#

i am looking for scrapping and bot developer
if you are high skilled dev, plz dm. I want high skill. if you can't provide me your recent similar project or experinece, don't waste time
this is will be long term relationship

clear venture
#

we will make your codebase gross dead

hybrid trail
#

we will replace sorted(s) with dir(type('',(),{'__dir__':lambda _:s})())

grave grail
#

imagine show no other activity that just advertising and expect high skill people to dm him πŸ’€

craggy hamlet
#

probably asking for it for free too

calm bloom
#

Hi,
I am working on a small project related to RAG and am stuck (Apparently cuz I don't know much)

I used mxbai-embed-large as embeddings and Chroma db as Vector store all goes well to this point.

Issue: When I try to retrieve data with similarity threshold it returns 0 docs and without threshold and k it always returns 4 docs no matter the query.
What is it that I am doing wrong?
Here my Code:

Vector Store Creation File:

# Load Docs and then store embeddings in the Chroma DB
from langchain_community.embeddings import OllamaEmbeddings
from langchain_community.document_loaders import PyMuPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_chroma import Chroma

embeddings = OllamaEmbeddings(
    base_url="http://43.204.231.131:11434",
    model="mxbai-embed-large",
)

loader = PyMuPDFLoader("./data/aliceShort.pdf")
data = loader.load()
# print(len(data))

text_splitter = RecursiveCharacterTextSplitter(
    # Set a really small chunk size, just to show.
    chunk_size=300,
    chunk_overlap=100,
    length_function=len,
    add_start_index=True,
)

chunks = text_splitter.split_documents(data)
print(f"Split {len(data)} documents into {len(chunks)} chunks.")


db = Chroma.from_documents(chunks, embeddings,persist_directory="./chroma_langchain_db")

query = "Who is Alice?"
docs = db.similarity_search(query)
print(docs[0].page_content)

Query File:

from langchain_community.embeddings import OllamaEmbeddings
from langchain_chroma import Chroma

embeddings = OllamaEmbeddings(
    base_url="http://65.2.37.27:11434",
    model="mxbai-embed-large",
)
db = Chroma(persist_directory="./chroma_langchain_db", embedding_function=embeddings)
query_text="Who is Alice?"
retriever = db.as_retriever(
    search_type="similarity_score_threshold", search_kwargs={"score_threshold": 0.1})
docs = retriever.invoke(query_text)
print(len(docs))
fleet bridge
calm bloom
fleet bridge
swift sparrow
#

Anyone had problems with pickle files getting corrupted? Im just reading them , but every couple months one (out of 3K) gets corrupted, almost always getting truncated. It never throws an error just silently delivers less data than it should. Windows machine. Also is this the right channel for that question

fleet bridge
#

sounds like you have a race condition

small pier
#

Hey guys, I've a question.
Usually we, the developers use git for committing our code changes and creating new branches for features and merging it with an existing branch.

So whenever I push my code to repo ( azure DevOps git repo) I need to some how generate a report like release notes.
How do I do that automatically? I've seen some people typing the commits manually in word document and making release notes.

fleet bridge
#

why did you decide to ask here?

arctic skiff
fleet bridge
#

im too tired today, sorry :(

median cloak
#
Ξ”ΞžΞ¨ = lambda Ξ·: (setattr(__import__("builtins"), 'Ξ', (Ξ := Ξ+1) if Ξ· == "Bell" else 0) or (
    (print("You Won £5"), setattr(__import__("builtins"), 'γ', γ+5), setattr(__import__("builtins"), 'Ξ', 0)) if Ξ == 3 else None) or (
    setattr(__import__("builtins"), 'Ξ¨', (Ξ¨ := Ξ¨+1) if Ξ· == "Skull" else 0) or (
    (print("You Lost Everything!"), setattr(__import__("builtins"), 'Ξ³', 0), setattr(__import__("builtins"), 'Ξ¨', 0)) if Ξ¨ == 3 else (
    print("You Lost Β£1"), setattr(__import__("builtins"), 'Ξ³', Ξ³-1), print(f"Balance: {Ξ³:.2f}") if Ξ¨ == 2 else None)))
``` i need more esotericness smhw
#

its too basic to submit as homework

median cloak
#

oh it got declined 😐

quartz wave
#

anyway

#
Ξ”ΞžΞ¨ = lambda Ξ·: (setattr(__loader__, 'Ξ', +(Ξ· == "Bell" and (Ξ := Ξ+1))) or (
    (print("You Won £5"), setattr(__loader__, 'γ', γ+5), setattr(__loader__, 'Ξ', 0)) if Ξ == 3 else None) or (
    setattr(__loader__, 'Ξ¨', +(Ξ· == "Skull" and (Ξ¨ := Ξ¨+1))) or (Ξ¨ == 3 and
    (print("You Lost Everything!"), setattr(__loader__, 'Ξ³', 0), setattr(__loader__, 'Ξ¨', 0)) or (
    print("You Lost Β£1"), setattr(__loader__, 'Ξ³', Ξ³-1), print(end=f"Balance: {Ξ³:.2f}\n"*(Ξ¨ == 2)))))
tepid otter
#

i feel like i can golf this further but im not seeing how (aim is to solve problem in minimal bytes)

"Line 1: An integer n for the number of integers.
Line 2: Integers of the list
Sum of resulted list with odds multiplied by 5 and evens by 3."

_,*x=map(int,open(0))
print(sum(map(lambda i:i*(3,5)[i%2],x)))
versed eagle
#

does that work

clear venture
#
print(sum([(v:=int(x))*(3,5)[v%2]for x in open(0)][1:]))
#

is that valid? I haven't used open(0) much but it's 6b less

versed eagle
#

yeah that should be equivalent

tepid otter
#

it probably would've, times up tho i dont have the test cases anymore lol. i was looking for something like that, but i was trying to do something like i*(2*(i%2+1)+1) or something

#

ended up being longer

clear venture
#

oh you don't even need the list comp there

#

oh nvm you do

#

for slicing

tepid otter
#

it mightve worked though

clear venture
#

isn't that what sum is doing

versed eagle
clear venture
#

when it runs the map calls

versed eagle
#

perfectly

tepid otter
#

sum would be iterating over the map, map would be reading the file object once per call

#

so not really

clear venture
#

the second object in map is iterated over

versed eagle
#

open(..) is a line iterator

tepid otter
#

but if it works it works

tepid otter
#

historically in these kinds of problems it just has not worked in some cases for me

#

it has problems being read all at once in certain ways

clear venture
#

shrug when you get this knee deep in cursed golf you just have to accept that it's weird and borkey

tepid otter
#

i really don't know why honestly

versed eagle
#

its just equivalent to an iterator over sys.stdin.readlines()

versed eagle
tepid otter
#

i immediately found a shorter way to do this but this was a funny solution for another challenge while it lasted:

s,r,i=input(),'',1
exec('r+=(s[0].lower(),s[0].upper())[i];i=(i+s[0].isalpha())%2;s=s[1:];'*len(s))
print(r)
clear venture
#

lol nice

#
print(sum([(v:=int(x))*7^2<<v%2for x in open(0)][1:]))
#

oh fuck

#

the operator precedence was fine until I added the * 😭

#

7^2<<v%2 gives 3 and 5

#

but since hecking * is higher than all of them but mod it ruins it Sadge

lofty obsidian
#

last time I saw one in python was a year ago

#

xor operator

quartz wave
grave grail
#

open(0)? WHat does this do?

#

!d open

#

no clue

earnest wing
#

In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically have non-negative integer values, with negative values being reserved to indicate "no value" or error con...

grave grail
#

ah, nice golf

quartz wave
grave grail
#

noticed, but just idk how it work

grave grail
digital dirge
rugged sparrow
#

Fun fact, open(0) and 0 will close the repl if you run it in the interactive terminal

jolly rock
#

Weird, why is that?

rugged sparrow
#

Because when the file object is freed, it closes the input file descriptor

#

Which means python gets the EOF error when trying to read the next character from the user

#

So it assumes the user hit ctrl-D

jolly rock
#

And that's how you would exit the repl I'm assuming

grave grail
#

open(0).close() would

quartz wave
#

do i have to use linux to get that bug?

grave grail
#

Probably, also on mac

rugged sparrow
vapid chasm
# stuck thorn !e ```py a=5 o="+" b=5 def calc(a,b,o): import os,sys,time if o not in [...

!e

a=5
o="+"
b=5
def calc(a,b,o):
    import os,sys,time
    if o not in ['+','-',':','x','^']:return
    ex="{0}{1}{2}".format("{}".format(a),o,"{}".format(b)).replace(':','/').replace('x','*').replace('^','**')
    for i in "{}".format(a):
        if i.isdigit():continue
        return
    for i in "{}".format(b):
        if i.isdigit():continue
        return    
    if o=="/" and b==0:raise ZeroDivisionError
    with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
    os.system("{0} {1}".format(sys.executable,"{}\\exec.py".format(os.getcwd())))
    with open("{}\\result".format(os.getcwd()),"r") as file:r=file.read()
    os.remove("{}\\result".format(os.getcwd()))
    return r
print(calc(a,b,o))
```print#export(:``walheck:)
night quarryBOT
# vapid chasm !e ```py a=5 o="+" b=5 def calc(a,b,o): import os,sys,time if o not in [...

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 20, in <module>
003 |     print(calc(a,b,o))
004 |           ^^^^^^^^^^^
005 |   File "/home/main.py", line 15, in calc
006 |     with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
007 |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
008 | OSError: [Errno 30] Read-only file system: '/home\\exec.py'
digital dirge
#

!e

globals().update(vars(__import__("ast")));exec(compile(fix_missing_locations(Module([FunctionDef('say_hello',arguments(posonlyargs=[],args=[],kwonlyargs=[],kw_defaults=[],defaults=[]),[Expr(Call(Name('print',Load()),[Constant('Hello!')],[]))],[]),Expr(Call(Name('say_hello',Load()),[],[]))],[])),"<string>","exec"))
night quarryBOT
digital dirge
#

Some dumbass on my server was ranting about whitespace

#

No whitespace, perfectly legible

versed eagle
digital dirge
#

newlines aren't real whitespace but fine πŸ˜„

versed eagle
digital dirge
#

mans citing rfcs now

#

i was just kidding, of course it's whitespace πŸ˜„

#

trivial whitespace tho

#

in terms of how hard it is to replace

versed eagle
#

i do agree that there should be some distinction between newlines and usual whitespace, since newline also resets the position horizontally of the cursor

#

whereas \hspace and \vspace just move it orthogonally

versed eagle
digital dirge
#

I just wanted to write from ast import * without spaces lemon_fingerguns_shades

#

Do you suppose there is a difference between that and globals().update(vars(__import__("ast")))? πŸ€”

versed eagle
#

from ... import * type imports respect the module's __dir__ attribute, if it has one

#

i dont think vars does, but i could be wrong

digital dirge
#

Ah, __all__ too, yeah

versed eagle
#

yeah

#

though you can just use importlib

#

spacelessly

digital dirge
#

How do you do a spaceless star import with importlib?

#

Apart from doing what I did and just replacing the __import__

versed eagle
#

i meant using __import__ (which is importlib.__import__) and manually emulating the from import behaviour

digital dirge
#

Wanna write it out? πŸ˜„

versed eagle
#

i do want to, but dont think i can rn (am on mobile currently)

#

perhaps in a few hours once i get home

gritty ferry
versed eagle
digital dirge
#

Man I was kidding about that ducky_drawing

digital dirge
gritty ferry
digital dirge
#

Eh, it's just cursed

#

But cursed stuff is fun

quartz wave
#

that's how i think it is

gritty ferry
grave grail
versed eagle
#

in my mind, whitespace ::= white-space | "\n" | "\r" | "\f" | (etc.)

digital dirge
fleet bridge
scarlet bone
#

is this oneliners?

grave grail
scarlet bone
grave grail
#

try out yourself

#

like

#

explain to ai how to do something similar

#

and see if it could do anything remotely similar to this

digital dirge
#

Lol good luck with that

digital dirge
#

God damn

#

!e

globals().update(vars(__import__("ast")));exec(compile(fix_missing_locations(Module([FunctionDef(name='fibonacci',args=arguments(posonlyargs=[],args=[arg(arg='n',annotation=None)],kwonlyargs=[],kw_defaults=[],defaults=[]),body=[If(test=Compare(left=Name(id='n',ctx=Load()),ops=[LtE()],comparators=[Constant(value=1)]),body=[Return(Name(id='n',ctx=Load()))],orelse=[]),Return(BinOp(left=Call(func=Name(id='fibonacci',ctx=Load()),args=[BinOp(left=Name(id='n',ctx=Load()),op=Sub(),right=Constant(value=1))],keywords=[]),op=Add(),right=Call(func=Name(id='fibonacci',ctx=Load()),args=[BinOp(left=Name(id='n',ctx=Load()),op=Sub(),right=Constant(value=2))],keywords=[])))],decorator_list=[]),Assign(targets=[Name(id='result',ctx=Store())],value=Call(func=Name(id='fibonacci',ctx=Load()),args=[Constant(value=7)],keywords=[])),Expr(Call(func=Name(id='print',ctx=Load()),args=[Name(id='result',ctx=Load())],keywords=[]))],[])),"<string>","exec"))
night quarryBOT
digital dirge
#

well that's it boys

#

pack up

#

we done

clear venture
#

lol

earnest wing
#

that's literally just using the well documented ast module to create a normal fib

digital dirge
#

Sure but I would've expected chatgpt to screw it up somehow

eager flame
#

Im kinda lost
Which is the correct channel for Machine Learning stuff?

grave grail
#

Ok we are done

grave grail
quartz wave
grave grail
#

πŸ’€

grave grail
#

And also, I guess, esoteric content is harder for AI to scrape?

quartz wave
#

what if AI speaks in esoteric

#

explains why it kind of sucks in normal code

#

but sort of works in the above example

earnest wing
grave grail
#

(if it could have scrape more, the quality of AI for code generation is most likely get lower lul

digital dirge
#

You're saying we should get gpt to produce the most cursed code possible and flood the internet with it? hyperlemon

earnest wing
unique heath
#

the anarchists in esopy :p

digital dirge
#

Oh, no, right, of course not πŸ˜‰

#

I definitely don't endorse it and haven't already started working on it either πŸ˜‰

#

None of us are organising in the underground with the goal to kill all AI πŸ˜‰

grave grail
#

πŸ’€

#

Well, only for python code generation

#

Or a more quantity of different variety of esoteric code probably harm more than repeated same content ig

arctic skiff
#

I wonder how much esoteric code can AI generate?

grave grail
#

Well, certainly not multi megabytes file

rugged sparrow
# digital dirge God damn

to be fair, GPT was likely trained on syntax trees specifically because it needs to rewrite code, and it would be easier to teach a model to round trip then it would be to get it to work inplace

digital dirge
#

I'm fairly certain it doesn't rewrite code by way of syntax trees but its all too complicated to understand anyways

arctic skiff
#

new quest: train a LLM to make esoteric code

digital dirge
#

You don't need to train it, you can just ask gpt

#

Here's your new new quest: write code so esoteric that gpt doesn't understand what it does

grave grail
#

Consider python is just one of the many languages in programming, which is just small aspect of the variety of topic in the world

fleet bridge
#

I am not surprised that it can spit out valid syntax trees
it is not a complicated transformation, you just encode the same meaning with different set of tokens

quartz wave
#

doesn't it just predict what comes next..?

versed eagle
#

yep

fleet bridge
#

large language models are good at language stuff, for example translating from one language to another
py->ast falls into "translation" category imo

jolly rock
#

Well natural languages and programming languages are fundamentally quite different I think

#

And LLMs are much better at natural languages than anything else (by the way I thought this was one of the off-topic channels, oops)

lapis kettle
#

is there any way to run a function using decorators without a space?

#
@eval
@input
class x:0

there is still space when define a class

hybrid trail
#

you could use a tab πŸ˜‰

lapis kettle
lapis kettle
#

\t\n\r\x0b\x0c

gleaming linden
#

the newline after the decorator is mandatory too

lapis kettle
gleaming linden
#

From the grammar ```
decorators: ('@' named_expression NEWLINE )+

Class definitions

-----------------

class_def:
| decorators class_def_raw
| class_def_raw

class_def_raw:
| 'class' NAME [type_params] ['(' [arguments] ')' ] ':' block

Function definitions

--------------------

function_def:
| decorators function_def_raw
| function_def_raw

function_def_raw:
| 'def' NAME [type_params] '(' [params] ')' ['->' expression ] ':' [func_type_comment] block
| ASYNC 'def' NAME [type_params] '(' [params] ')' ['->' expression ] ':' [func_type_comment] block

#

there are no mentions of decorators anywhere else

#

and they can only be used with 'def' NAME ... and 'class' NAME ...

#

so unless you can separate a keyword and identifier without a space it's impossible

pallid edge
#

where is the tab for helping

grave grail
sick hound
#

Ok so when you call a class method, for example, obj.do_stuff(), by default:

  1. The interpreter checks obj.__dict__ and if finds the attribute there, then it returns the value, and assuming its a callable, it does not touch its __self__ attribute
    2: The interpreter checks obj.__class__.__dict__ and if finds the attribute there, then it returns the value, and assuming its a callable, it does set its __self__ attribute to obj
#

3: And if everything fails then __getattr__ happens

#

But, is there any way to dinamically define instance method objects in __getattr__ so that their __self__ parameter is set to obj when __getattr__ is called?

#

idk if im making any sense

#

and obviously i see 0 use cases for this but we`re here in esoteric for a reason lmao

restive void
#

!e

class X:
    def __getattr__(self, attr):
        def fakemethod(name):
            print(attr, "says", name)
        return fakemethod

x = X()
x.foo("bar")
night quarryBOT