#esoteric-python

1 messages · Page 46 of 1

sick hound
#

i rather mean something like:

class Thing:
    def __init__(self, msg):
        self.msg = msg

    def __getattr__(self, attr)
        def fakemethod(inner_self)
            print(inner_self.msg)
        fakemethod.__self__ = self
        return fakemethod
#
obj = Thing("This should print")
obj.fakemethod() # msg should print
restive void
night quarryBOT
restive void
night quarryBOT
halcyon pewter
#

Weird question...
I want to call a class method that I have in several classes, inside a function that can take an object of any of these classes. How can I determine which class to call the method from?
Simplified example:

class Person:
    def get_from_file(self, name, age, home):
        ...
class Student(Person):
    def get_from_file(self, name, age, home, year, house):
        ...
class Teacher(Person):
    def get_from_file(self, name, age, home, subject):
        ...
class House:
    def get_from_file(self, name, founder, animal, values):
        ...
    
def genericLoader(file_name, delimiter, **kwargs):
    ...
    my_object = <CORRECT CLASS NAME>.get_from_file(kwargs)
    ...`

Is there a way to determine it, or do I just if elif elif else?

versed eagle
#

if thats what you mean

halcyon pewter
#

No, I mean something that I can replace <CORRECT CLASS NAME> with

versed eagle
#

so just obj.class_method()

halcyon pewter
#

Ahh ok, I missunderstood what you meant first. That works, thanks

digital dirge
#

not esoteric enough

halcyon pewter
#

Yeah, I just didn't consider that I could do it from the object name, I thought I needed to get the class name from it somehow

clear venture
#

I'd imagine it's pretty terrible at guessing what any golfed code over 500b does unless that code provides easy context for it (like the strings "rock", "paper", and "scissors" being in the code)

#

and beyond that easy to trick by including fake contextual clues like those mentioned above

jolly rock
#

I wonder if anyone fine-tuned a model to specifically output golfed code

clear venture
#

probably not, I'd imagine if you could get some pretty strong outputs from it if you treated it like an RAG with COT

#

except instead of actually needing retrieval based augmentation you feed the same "this is how you turn a for loop into a comprehension or get the same result using map blah blah" into the input every time

#

no need for fine tuning really

vast wave
#

it couldnt tell me exactly what pattern was being drawn but it got the gist of it

#

surprising

earnest wing
#

Not so surprising; the code imports trig functions, prints with ANSI escapes, and contains a short sleep inside a forever loop

ruby valley
#

I am going to build youtube channel claimer. Old youtube channels, I am gonna claim the ownership. It is kind of automation project by python programming. If someone is expert in automation, let's connect!

night quarryBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

sick hound
#

it returns an ordered list in which the order of the resolution of methods is specified

#

iirc phyton uses the c3 algo??

#

idk

#

but the rule of thumb is:

  • 1: The method in the class itself
  • 2: The method in the parent class in order of inheritance
fleet bridge
#

there is no need to use .mro()

#

it is used very rarely in some obscure situations

digital dirge
#

Would you say, it's usage is mostly... esoteric? lemon_fingerguns_shades

warm cape
#

I did this long time ago, printing false for true and such stuff, I don't really remember the code

Have I done anything wrong here that I get no output?```py
from ctypes import py_object

py_object.from_address(id(True) + 8).value = False
print(f"True: {True}")

versed eagle
quartz wave
#

so id(True) + 8 would mean changing the True object's type instead of its value

warm cape
#

I have a code from some years ago, which is unreadable to me but still works

#

It does the same thing but I can't figure it out

#

Here's the code(requires internet to run)```py
_ = import('ctypes').py_object.from_address
__ = import(''.join([chr(int(i)) for i in '114 101 113 117 101 115 116 115'.split()])).get

class TheStart(metaclass=type(
'',
(type,),
{
'prepare': lambda *a: type(
'',
(dict,),
{
'missing': lambda *a: getattr(builtins, a[1], 1),
'contains': lambda *a: bool('')
}
)()
}
)): (globals().setitem('hack', lambda x, y: setattr(
(id(x)+8), "value", type('', (), {'str': lambda _: y})))); globals().setitem('d', lambda _: ''.join([chr(int(i)) for i in _.split()]))

hack(True, __(d('104 116 116 112 115 58 47 47 119 119 119 46 101 105 103 104 116 98 97 108 108 97 112 105 46 99 111 109 47 97 112 105')).text[12:-3])

class Love(TheStart):
print(Destiny is us)#?

versed eagle
#

why do you need requests...

#

wtf is https://www.eightballapi.com/api

halcyon pewter
versed eagle
versed eagle
#

!e ```py
import ctypes
setattr(ctypes.py_object.from_address(id(True)+8), "value", type('', (), {'str': lambda _: "hello, world"}))
print(True)

night quarryBOT
versed eagle
warm cape
#

oh I'm changing string repr

#

😑

#

thought i was actually changing

warm cape
warm cape
#

for no reason ever I'm going to make it a single line

weak turret
#

I never checked this channel, what is the point of it?

#

The description doesn't give that much info

#

Lambdas aren't esoteric or something

warm cape
weak turret
#

I know about esoteric languages a lot, and python, well, isn't one, so I can't understand the meaning of this channel, unless its just for "weird code", but then again: why use an already reserved word for something unrelated.

#

It shouldn't have been named this way

#

Yo didn't expect you here, deleted

grave grail
weak turret
grave grail
#

lul

west trail
#

!e

from itertools import permutations

def calc(n):
    def f(x):
        return x**2 - 4*x + 4
    return f(n) // 2

def obscure(n):
    return calc(n) - sum(map(lambda x: x**2, range(n)))

def mystify(data):
    return [hex(x) for x in data]

class Enigma:
    def __init__(self, seed):
        self.seed = seed
        self.data = mystify([self.seed] * 5)
    
    def process(self):
        perm = permutations(range(5))
        result = [0]
        for p in perm:
            temp = self.seed
            for idx in p:
                temp = obscure(temp) + idx
            result.append(temp)
        return result
    
    def __str__(self):
        return str(self.data)

e = Enigma(42)
print(e.process())
night quarryBOT
west trail
#

!e

from functools import reduce
import itertools as it

def f(a, b):
    return reduce(lambda x, y: x ^ y, map(ord, b), a)

def g(x):
    return ''.join(chr(c) for c in it.accumulate(x, lambda a, b: a + b))

def h(s):
    return [ord(c) for c in s]

def i():
    return list(it.chain.from_iterable(map(lambda c: [c] * 3, [i for i in range(10)])))

a = f(0, 'This is an example!')
b = h(''.join(chr(i) for i in i()))
c = g([c - a for c in b])

print(c)
night quarryBOT
# west trail !e ```py from functools import reduce import itertools as it def f(a, b): r...

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

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 18, in <module>
003 |     c = g([c - a for c in b])
004 |         ^^^^^^^^^^^^^^^^^^^^^
005 |   File "/home/main.py", line 8, in g
006 |     return ''.join(chr(c) for c in it.accumulate(x, lambda a, b: a + b))
007 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
008 |   File "/home/main.py", line 8, in <genexpr>
009 |     return ''.join(chr(c) for c in it.accumulate(x, lambda a, b: a + b))
... (truncated - too many lines)

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

west trail
#

!e

def Ω(𝛿):
    return 𝛿 * (𝛿 - 1) // 2

def Ψ(Φ):
    return [(λ := λ + 1) for λ in range(Φ)]

def Δ(Ξ):
    return {ξ: ξ * ξ for ξ in Ξ}

def Σ():
    ∆ = 42
    Γ = Ω(∆)
    δ = Ψ(Γ)
    φ = Δ(δ)
    return φ[Γ % len φ]

print(Σ())
night quarryBOT
arctic skiff
versed eagle
#

chilaxan and cereal both have made cool things

#

death.py but i think they changed names now

#

and they haven't been active recently

#

and l3viathan

#

lots of people make cool things here

earnest wing
#

yeah

versed eagle
#

oh hi olivia!

earnest wing
#

hi kotnen!

versed eagle
earnest wing
#

🐦

versed eagle
#

oh i forgot my nickname isnt set here miau

#

ok fixed

versed eagle
# weak turret I know about esoteric languages a lot, and python, well, isn't one, so I can't u...

anyway, as to your point about this not being esoteric, my dictionary gives the following definitions for ``esoteric'':

  1. Intended for or likely to be understood by only a small number of people with a specialized knowledge or interest, or an enlightened inner circle.

  2. Having to do with concepts that are highly theoretical and without obvious practical application; often with mystical or religious connotations.

i think the stuff here generally meets both of those definitions
and more generally, who's to say what's esoteric and what isn't?

#

l3viathan said this once and i think its a really nice way of putting it

#

ok ill step off my soapbox now!

earnest wing
#

aside from the dictionary
"esoteric" in the context of esolangs is not a magic word reserved to esolangs

#

the same meaning can be derived from esoteric application of practical languages

hybrid trail
#

silly little challenge: write a program that will determine if a given number is odd, like the following:

print(int(input()) % 2 == 1)

the catch is your code can only use the characters a-z and parentheses

hybrid trail
#

yep

restive void
#

Do you have a solution? Because I don't see how you could do that without at least .

hybrid trail
#

i do

restive void
#

Ok, then let me think :)

hybrid trail
#

no eval or exec either

restive void
hybrid trail
#

that was quick!

#

shorter than my solution too, I did print(next(reversed(bin(int(input()))))in(str(int(not(())))))

restive void
#

Oh, right, I don't need the iter(); print(bool(int(next(reversed(bin(int(input()))))))) then

restive void
fleet bridge
#
>>> input = lambda: 42
>>> ~() // input // str // reversed // next // ord // bin // reversed // next // int
0
>>> input = lambda: 69
>>> ~() // input // str // reversed // next // ord // bin // reversed // next // int
1
#
>>> input = lambda: 42
>>> int(next(reversed(bin(ord(next(reversed(str(input()))))))))
0
>>> input = lambda: 69
>>> int(next(reversed(bin(ord(next(reversed(str(input()))))))))
1
#

ok, that is a lot longer than your solution

#

what the hell did i just wrote
why does input() returns an int, and why do i convert it to a string...

#

for some reason i have a function called rocket_stages available in my repl... ```py

rocket_stages?
Help on function rocket_stages in module sc:

rocket_stages(ssto_payload_ratio: 'float', payload_mass: 'float' = 1, n_stages: 'int' = 2, k: 'int' = 3) -> 'list[float]'

inspect.getsource(rocket_stages) // print
def rocket_stages(
ssto_payload_ratio: float,
payload_mass: float = 1,
n_stages: int = 2,
k: int = 3,
) -> list[float]:

    # >>> rocket_stages(0.02, n_stages=5, payload_mass=1000, k=0)
    # [27_134, 12_408, 5_674, 2_595, 1_186, 1_000]
    # >>> [(x[:i+1]//sum, x[i:] // sum * 1.5 // 400,)for i in range(len(x))]
    # [(num of engines, mass including this stage), ...]
    q = ssto_payload_ratio
    res = [q ** ((i - 1) / n_stages) - q ** (i / n_stages) for i in range(1, n_stages + 1)]
    total = payload_mass / (1 - sum(res))
    res = [total * x for x in res]
    res = [round(x, k) if k else int(x) for x in res]
    res += [payload_mass]
    return res
rugged sparrow
hybrid trail
grave grail
#

What composite mean(?

versed eagle
#

“composed” of multiplications by prime numbers

grave grail
#

Thx

hybrid trail
#

no

versed eagle
#

no divmod nor pow

#

im assuming no exec/eval, right

simple sphinx
#

yea the commas are hard

hybrid trail
simple sphinx
#

am I supposed to create a function? or am I allowed to hardcode the number?

hybrid trail
#

write a full program with print to output and input for input

hybrid trail
#

yes

simple sphinx
#

I can only get it with spaces oof

#

I got it with no spaces and a single ":" might be getting somewhere

subtle viper
#

no symbols is a bit hard T-T

hybrid trail
#

nope

simple sphinx
#

making sure exec and eval are banned right?

hybrid trail
#

as a hint, this is the exact test my solution uses for determining if a number is composite: ||n is composite if and only if there are integers a, b greater than one such that a*b=n (basically the most naive algorithm)||

earnest wing
#

solution ||print(any((sum((c)for(z)in(range(b)))in((a)for(z)in(range(not()))))for(a)in((int(input()))for(z)in(range(not())))for(b)in(range(a))for(c)in(range(a))))||

grave grail
earnest wing
#

you can do it with just 1

grave grail
#

Oh right I cannot use %

#

I have no clue lul, just reading answer

#

At this point

hybrid trail
grave grail
#

Let me try this

hybrid trail
grave grail
#

Thinking how to get -1

hybrid trail
#

if you want to decrease a positive integer by one I think the simplest way is max(range(n))

grave grail
#

I was on track of thinking a*b-n=0 but you need -n part

hybrid trail
#

a*b = n is simpler to implement

grave grail
#

But you cannot have ==?

hybrid trail
#

you can use in

grave grail
#

Hmm right

fleet bridge
#

||```py
print(next(int(not(not()))in((x*y-n)for(x)in(range(n))if(x)and(next(reversed(range(x))))for(y)in(range(n))if(y)and(next(reversed(range(y)))))for(n)in(int(input()),)))

illegal chars used: *-, (each only once)

print(next((n)in((x*y)for(x)in(range(n))if(x)and(next(reversed(range(x))))for(y)in(range(n))if(y)and(next(reversed(range(y)))))for(n)in(int(input()),)))

illegal chars used: *,

print(next((n)in((len(list(()for(i)in(range(x))for(j)in(range(y)))))for(x)in(range(n))if(x)and(next(reversed(range(x))))for(y)in(range(n))if(y)and(next(reversed(range(y)))))for(n)in(int(input()),)))

illegal chars used: ,

hybrid trail
#

||you're on the right track, there are ways to get rid of each of those illegal chracters||

grave grail
#

||

y = 5
input = lambda*_: y

print(not(any(list(sum((a)for(c)in(range(b)))in(input(),input())for(a)in(range(input()))for(b)in(range(input()))))))

Require multiple use of input
||

#

Oh oops

#

The comma

#

And I thought better way now

#

Wait no it doesn't

#

Got it
||


y = 11
input = lambda*_: y

print(not(any(list(sum((a)for(c)in(range(b)))in(input()for(z)in(range(not())))for(a)in(range(input()))for(b)in(range(input()))))))

||

#

Oops, forgot spoiler, did now

hybrid trail
#

now can you figure out how to do it without repeating input? 😉

grave grail
#

And... I am clueless at this point 💀

#

Better start going back and continue write bot

fleet bridge
#

does this count? ||```py
print(
int(input())
in (
sum((x)for(i)in(range(y)))
for (x) in (range(500))
if (x) and (next(reversed(range(x))))
for (y) in (range(500))
if (y) and (next(reversed(range(y))))
)
)

hybrid trail
#

side note, i wonder if it is possible to make an infinite iterator

#

then we would have an infinite range with something like (next(iter(a))for(a)in(enumerate(infiterator)))

fleet bridge
#
>>> max('ab', 'b')
'b'
>>> max('ab')
'b'
earnest wing
fleet bridge
#

||iter(list,callable) is an infinite iterator||

hybrid trail
earnest wing
#

unrelated to this specific challenge, but you can absolutely exec arbitrary code under this ruleset

hybrid trail
#

by using exec?

digital dirge
#

Is it turing complete? 😄

fleet bridge
#
x - 1 == next(reversed(range(x))) # for x >= 1
x - 1 == max(range(x)) # for x >= 1
x * y == sum((x)for(i)in(range(y)))  # for y >= 0
x > 0 == bool(range(x))
[x,y] == list((y)if(bool(range(i)))else(x)for(i)in(range(len(str(())))))
x + y == sum([x,y])
2 == len(str(()))
1 == int(not())
0 == int()
18 == hash(id) // abs // hex // len
65 == hash(id) // abs // bin // len
``` that is a list of simple operations i figured out how to do

idk how to do `-x`, it can be done as `(-1) * x`, but it requires `-1`
after that `x - y` can be done as `x + (-y)`
earnest wing
#

||exec(bytes(iterable)), where iterable is constructed like ((c1)if(i==0)else(c2)if(i==1)else(...)for(i)in(range(N)), x==y is constructed like (x)in((y)for(z)in(range(not()))) and arbitrary integers c1, c2, ... & Nare constructed any way you like (for example starting with a number like len(str(object)) and either decrementing it using max(range(n)) or increasing it a lot using sum(range(n)) )||

fleet bridge
hybrid trail
fleet bridge
#

so it is turing complete if we use exec/eval

hybrid trail
#

without using those, it is much harder. For example I think it is impossible to make a program that just prints TrueFalse

fleet bridge
#

chr(n) gives you arbitrary character
is it possible to perform string concatenation somehow?

hybrid trail
#

if we could get the values of a dictionary we could iterate over vars(str) to find str.join but there seems to be no way to do that either

fleet bridge
#
(type)(int)(list)(str)(dict)
``` this is valid code 😄
#
>>> [next(reversed(kv)) for kv in vars(str).items() if ord(next(iter(next(iter(kv))))) == ord('j')]
[str.join]
``` uses `.items`
#

next(iter(next(iter(kv))))
cursed

digital dirge
#

Love the activity here today, very esoteric stuff 😄

#

Well, not esoteric

#

But you know

#

Weird 😄

hybrid trail
#

I guess then we would need bytes.decode, not str.join

#

because we know how to make arbitrary bytestrings, but can't turn them back into strings

fleet bridge
hybrid trail
#

doesn't work for me

digital dirge
#

nah

fleet bridge
#

oh, right
i forgot it needs second arg :)

digital dirge
hybrid trail
#

list((3)for(o)in(str(int()))) is the shortest I know of

digital dirge
#

Ah, right

arctic dawn
#

Hi

quartz wave
#

shortest code competition..?

grave grail
#

Oh, so I don't have to invert it? Whatever

quartz wave
#

143 -> 123 ||```py
print(any((I)in(sum((a)for(z)in(bytes(b)))for(b)in(range(I)))for(I)in(int(input())for(i)in(chr(not())))for(a)in(range(I))))

hybrid trail
#

🤯

#

i was ready to accept 144 as optimal and then you shave 20 more bytes...

fathom panther
#

What da hell is that

hybrid trail
# fathom panther What da hell is that

we were trying to write a prime checker in python but all of our keyboards broke simultaneously, allowing us to only type lowercase letters and parentheses into the python interpreter

fleet bridge
#

is it possible to check if number is perfect?

#

In number theory, a perfect number is a positive integer that is equal to the sum of its positive proper divisors, that is, divisors excluding the number itself. For instance, 6 has proper divisors 1, 2 and 3, and 1 + 2 + 3 = 6, so 6 is a perfect number. The next perfect number is 28, since 1 + 2 + 4 + 7 + 14 = 28.
The sum of proper divisors of ...

#

I think it is pretty straightforward

versed eagle
fathom panther
hybrid trail
#

so far i've got 191 203

#

however it falsely marks 1 as perfect

#

is that fine?

fleet bridge
#

isn't it perfect?

#

ah, excluding itself

versed eagle
#

for whatever condition checking you've got going on

hybrid trail
#

I wanted to operator chain like .... in [N] not in range(2) but you can't do not in without spaces :(

simple sphinx
#

omg you can do for i in something by using parans

quartz wave
#

how to + 1?

simple sphinx
#

I got lost in the sauce

quartz wave
fleet bridge
quartz wave
fleet bridge
#

then I don't know

quartz wave
#

eh anyway

#

||```py
print(not(any(sum((a)for(a)in(range(I))if(I)in(sum((a)for(z)in(bytes(b)))for(b)in(range(I)))or(a)and(not(max(range(a)))))in(range(I))for(I)in(int(input())for(i)in(chr(not()))))))

fleet bridge
#

am I right that you can replace bytes with range ?

fathom panther
#

!e

print(not(any(sum((a)for(a)in(range(I))if(I)in(sum((a)for(z)in(bytes(b)))for(b)in(range(I)))or(a)and(not(max(range(a)))))in(range(I))for(I)in(int(input())for(i)in(chr(not()))))))
night quarryBOT
# fathom panther !e ```py print(not(any(sum((a)for(a)in(range(I))if(I)in(sum((a)for(z)in(bytes(b)...

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

:warning: Note: input is not supported by the bot :warning:

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print(not(any(sum((a)for(a)in(range(I))if(I)in(sum((a)for(z)in(bytes(b)))for(b)in(range(I)))or(a)and(not(max(range(a)))))in(range(I))for(I)in(int(input())for(i)in(chr(not()))))))
004 |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
005 |   File "/home/main.py", line 1, in <genexpr>
006 |     print(not(any(sum((a)for(a)in(range(I))if(I)in(sum((a)for(z)in(bytes(b)))for(b)in(range(I)))or(a)and(not(max(range(a)))))in(range(I))for(I)in(int(input())for(i)in(chr(not()))))))
007 |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
008 |   File "/home/main.py", line 1, in <genexpr>
009 |     print(not(any(sum((a)for(a)in(range(I))if(I)i
... (truncated - too long, too many lines)

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

fathom panther
#

Wow

#

What does EOF mean

versed eagle
fleet bridge
hybrid trail
#

negating the any is very smart

versed eagle
#

hm

hybrid trail
#

I tried checking if sum(...) == n - 1

versed eagle
#

it would be fun to write a converter between some python expressions and this maybe

quartz wave
versed eagle
#

not arbitrary python expressions, but a large subset of the builtin functions could be done mechanically i think

#

new project idea!

fleet bridge
#

it might be expensive in terms of both code size and runtime performance

quartz wave
hybrid trail
#
print(any(
    (N-1) in # N is equal to ...
    [sum(a for a in range(N) if N in (a*b for b in range(N)))] # the sum of its divisors
    and not(N in range(2))

    for N in [int(input())]
))
``` works for me
#

which is the deobfuscated version of my solution

versed eagle
#

but it would be fun!

hybrid trail
hybrid trail
#

seems like you don't take into account abundant numbers

#

my 201:
||py print(any(max(range(N))in(sum((a)for(a)in(range(N))if(N)in(sum((a)for(e)in(range(b)))for(b)in(range(N))))for(d)in(dir()))and(not((N)in(range(len(str(()))))))for(N)in(int(input())for(f)in(str(int())))))||

quartz wave
hybrid trail
#

174 by ||golfing the 1 check

print(any(sum((a)for(a)in(range(I))if(I)in(sum((a)for(z)in(bytes(b)))for(b)in(range(I)))or(a)is(int(not())))in((I)for(z)in(dir()))for(I)in(int(input())for(i)in(chr(not())))))
```||
warm cape
#

what u guys doing

hybrid trail
#

using only characters a-z and parens to code

clear venture
#

using parens instead of spaces is kinda cancer to read lol

#

chr(not()) evaluates to '\x01' yeah?

#

isn't that shorter

versed eagle
#

no quotes

#

nor backslashes

clear venture
#

oh

versed eagle
#

nor numbers

#

only a-z and parens

quartz wave
warm cape
hybrid trail
#

swag

warm cape
#

mind to elaborate?

earnest wing
#

there were two prompts, one to create a program that determines whether a number is divisible by 2 and another for whether it's non-prime

quartz wave
grave grail
#

But why?

earnest wing
grave grail
#

I don't think there are any valid use case for this: What you can achieve with or with capital is like the same if I'm not wrong

jovial token
grave grail
earnest wing
#

not() and bool()

grave grail
jovial token
#

something funny i just realised

print(list(str(a)for(a)in(str(input()))))
earnest wing
grave grail
#

Oh, I thought they exist as both form

#

(Which would be weird but I never have a thought about it previously

jovial token
#

3455 returns True

gleaming linden
#

#1279819295219777577

t=n=10**999;exec("n=n//2+t*t//n;"*99);print(f"1.{n-t}")

sqrt(2) to 1k digits
55b so far

hybrid trail
somber raptor
#
result = (lambda _, __, ___, ____, _____, ______, _______, ________:
    getattr(
        __import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
        ().__class__.__eq__.__class__.__name__[:__] +
        ().__iter__().__class__.__name__[_____:________]
    )(
        (lambda _, __, ___: _(_, __, ___))(
            lambda _, __, ___:
                bytes([___ % __]) + _(_, __, ___ // __) if ___ else
                (lambda: _).func_code.co_lnotab,
            _ << ________,
            (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
            - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
            __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
            << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
            ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
            __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
            << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
            _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
            (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
            _))) + (_____ << ______) + (_ << ___)
        )
    )
)(
    *(
        [len] +
        [ord] +
        [sum] +
        [int] +
        list(range(7))
    )
)

decode this without running it, i dare ypu

karmic pumice
#

!e

result = (lambda _, __, ___, ____, _____, ______, _______, ________:
    getattr(
        __import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
        ().__class__.__eq__.__class__.__name__[:__] +
        ().__iter__().__class__.__name__[_____:________]
    )(
        (lambda _, __, ___: _(_, __, ___))(
            lambda _, __, ___:
                bytes([___ % __]) + _(_, __, ___ // __) if ___ else
                (lambda: _).func_code.co_lnotab,
            _ << ________,
            (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
            - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
            __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
            << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
            ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
            __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
            << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
            _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
            (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
            _))) + (_____ << ______) + (_ << ___)
        )
    )
)(
    *(
        [len] +
        [ord] +
        [sum] +
        [int] +
        list(range(7))
    )
)
night quarryBOT
karmic pumice
#

yeah its not like it can be ran anyways

steep surge
#

!hell

karmic pumice
# karmic pumice yeah its not like it can be ran anyways

it also does (lambda: _).func_code.co_lnotab which just doesnt make sense? maybe this branch was never supposed to be taken i guess
and it does True.__class__.__name__[_] which even if it was called with the right amount of args would try to index a string with.. len? yeah im not sure how this was even supposed to work

placid lynx
#

After deobguscationg lua scripts i trained my brain

sick hound
#

Make a weird function that checks if all ints in a list are ones

def allOnes(_n:list[int])->bool:return(all(u==1 for u in _n))
placid lynx
#

How i think

#

It have intto string convertion

#

And it uses that shit long bit operations

#

To get string

#

And then idk

placid lynx
#
def allOnes(n: list[int]) -> False:
 if not isinstance(n, list):
  return False
 a = 0
 for item in n:
  if item == 1:
   a += 1
 return a == len(n)
#

Real sigmas do this^

karmic pumice
#

!e

import re
allOnes=lambda n:bool(re.fullmatch(' '.join('1'*len(n)),' '.join(map(repr,n))))
assert allOnes([])
assert allOnes([1])
assert allOnes([1, 1])
assert not allOnes([1, 2, 1])
night quarryBOT
karmic pumice
#

!e

allOnes=(lambda f:lambda*p:(q:=[f(*p)],sum(iter(lambda:(q.__setitem__(0,f(*q[0][1])),0)[1]if(q[0][0])else(1),1)))[0][0][1])(lambda n,i=0:((0,False)if(n[i]!=1)else(1,(n,i+1)))if(i<len(n))else(0,True))
assert allOnes([])
assert allOnes([1])
assert allOnes([1, 1])
assert not allOnes([1, 2, 1])
night quarryBOT
karmic pumice
quartz wave
quartz wave
#

(well technically it's an inverted prime checker)

jovial token
quartz wave
#

oh-

#

it's none of what i just said T^T

versed eagle
#

definitionally

warm cape
#

can you guys use all_ones and not allOnes

quartz wave
karmic pumice
#

mentioned

quartz wave
# sick hound Make a weird function that checks if all ints in a list are ones ```py def allOn...

!e ```py
from typing import Callable, Iterable

def equal_to[T](v: T) -> Callable[[T], bool]:
def _is_equal(x: T) -> bool:
return x == v
return _is_equal

def all_is[T](f: Callable[[T], bool]) -> Callable[[Iterable[T]], bool]:
def _all_check_is(it: Iterable[T]) -> bool:
return all(map(f, it))
return _all_check_is

allOnes = all_is(equal_to(1))
assert allOnes([])
assert allOnes([1])
assert allOnes([1, 1])
assert not allOnes([1, 2, 1])
print("passed")

night quarryBOT
karmic pumice
#
@overload
def allOnes(xs: list[Literal[1]]) -> Literal[True]:
  ...
@overload
def allOnes(xs: list[int]) -> bool:
  ...
karmic pumice
quartz wave
#

$ and $n are already reserved syntaxes for "templates"

#

where y |> (x |> f($, $1)) is basically equivalent to f(x, y)

#

and $ == $0

karmic pumice
#

but this is the same thing except without the pipes, its just not applied yet

quartz wave
#

yea but it's ambiguous to figure out which refers to which if both are used

#

..how about something like a prefix &

karmic pumice
#

all ∘ map (==1)

quartz wave
#

map(1 .__eq__, xs) |> all?

#

oh yea no argument names-

#

function composition is still unimplemented too, hmm

#

plus that weird bug with templates that i haven't fixed yet T^T

#

god i have so much i wanna do..

warm cape
quartz wave
grave grail
#

Need to learn more on how typestub give better understand to type checker on what your code do

quartz wave
#

but i don't know how typing works soo 🤷‍♂️

grave grail
#

Why Protocol

#

I.e. what does it explain more than that to type checker

karmic pumice
digital dirge
#

Everytime I've used overloads I've ended up refactoring the code later

karmic pumice
#

every time i've used typing in python i've ended up switching to a different language
-# /hj

grave grail
digital dirge
#

So now whenever I feel like I need them that's just a signal to take a step back

karmic pumice
digital dirge
quartz wave
#

but i don't know how typing works soo

karmic pumice
#

if you want eq(1) -> bool and eq(object) -> bool its just eq(object) -> bool (since 1 is an object) which is just object's __eq__
so like just list[object]

fleet bridge
quartz wave
#
class HasEq[T](Protocol):
    @overload
    def __eq__(self, __x: Literal[1]) -> bool:
        ...
    @overload
    def __eq__(self, __x: object) -> bool | NotImplementedType:
        ...
``` ?
karmic pumice
#

notimplemented is not needed in types (you can always use a NotImplemented), so you're once again back to just object.__eq__

quartz wave
#

yea but how would i annotate __eq__ for Literal[1] with a strictly bool output

karmic pumice
#

eq with anything is already supposed to be a bool

quartz wave
karmic pumice
#

numpy is weird indeed

fleet bridge
#

!d object.eq

night quarryBOT
#

object.__eq__(self, other)``````py

object.__ne__(self, other)``````py

object.__gt__(self, other)```
These are the so\-called “rich comparison” methods. The correspondence between operator symbols and method names is as follows: `x<y` calls `x.__lt__(y)`, `x<=y` calls `x.__le__(y)`, `x==y` calls `x.__eq__(y)`, `x!=y` calls `x.__ne__(y)`, `x>y` calls `x.__gt__(y)`, and `x>=y` calls `x.__ge__(y)`.

A rich comparison method may return the singleton [`NotImplemented`](https://docs.python.org/3/library/constants.html#NotImplemented) if it does not implement the operation for a given pair of arguments. By convention, `False` and `True` are returned for a successful comparison. However, these methods can return any value, so if the comparison operator is used in a Boolean context (e.g., in the condition of an `if` statement), Python will call [`bool()`](https://docs.python.org/3/library/functions.html#bool) on the value to determine if the result is true or false.
quartz wave
#

after spending some time going down the typing rabbit hole i have finally convinced myself to stop

grave grail
earnest wing
karmic pumice
#

ooh codecs cool
its so sad that they are.. not supported by any static analysis tools, so using them in real code is practically impossible

earnest wing
#

it would be goofy

#

but you could add a mypy module

digital dirge
night quarryBOT
versed eagle
spring perch
#

can we create non-alphanumeric python3 code?

restive void
spring perch
#

what does codec mean? why not counting them?

restive void
spring perch
#

i see, but codec comment include alphanumeric characters.

#

it includes "codec"

restive void
#

Right, so that wouldn't work anyways

stuck thorn
night quarryBOT
digital dirge
night quarryBOT
versed eagle
digital dirge
#

I know?

digital dirge
#

That's not my submission

#

Mine is above and all_ones([]) returns True

versed eagle
# placid lynx

yes, and im saying that this specific part is incorrect

versed eagle
#

it wasnt directed at you

digital dirge
#

Aight, no worries

placid lynx
#

!e

result = chr(
    int(
        ord(NameError.__class__.__eq__.__name__[len([].__class__.__name__)])
        + len(True.__class__.__name__) * (len(True.__class__.__name__) + len(None.__class__.__name__)) // len(None.__class__.__name__)
        + (len(True.__class__.__name__) - len(NameError.__class__.__name__))
        + len(True.__class__.__name__) + len(None.__class__.__name__) - (len(print.__class__.__eq__.__name__) - len(object.__class__.__name__))
    )
) + chr(
    int(
        ord(NameError.__class__.__eq__.__name__[len([].__class__.__name__)])
        + len(True.__class__.__name__) // len(None.__class__.__name__) * len(None.__class__.__name__)
        + (len(True.__class__.__name__) - len(NameError.__class__.__name__))
        + (len(True.__class__.__name__) - (len(None.__class__.__name__) - (len(True.__class__.__name__) + len(None.__class__.__name__))))
        + len(True.__class__.__name__) + len(None.__class__.__name__)
    )
)


print('Result: ', result)
night quarryBOT
placid lynx
#

!e

print((lambda _, __, ___, ____: getattr(__import__(_(
    ____(
        __(NameError.__class__.__eq__.__name__[___([].__class__.__name__)])
        + ___(True.__class__.__name__) * (___(True.__class__.__name__) + ___(None.__class__.__name__)) // ___(None.__class__.__name__)
        + (___(True.__class__.__name__) - ___(NameError.__class__.__name__))
        + ___(True.__class__.__name__) + ___(None.__class__.__name__) - (___(print.__class__.__eq__.__name__) - ___(object.__class__.__name__))
    )
) + _(
    ____(
        __(NameError.__class__.__eq__.__name__[___([].__class__.__name__)])
        + ___(True.__class__.__name__) // ___(None.__class__.__name__) * ___(None.__class__.__name__)
        + (___(True.__class__.__name__) - ___(NameError.__class__.__name__))
        + (___(True.__class__.__name__) - (___(None.__class__.__name__) - (___(True.__class__.__name__) + ___(None.__class__.__name__))))
        + ___(True.__class__.__name__) + ___(None.__class__.__name__)
    )
)), 'name'))(*([chr]+[ord]+[len]+[int])))
night quarryBOT
placid lynx
grave grail
#

For the least, is it possible to print the input by that?

restive void
grave grail
#

So some sort of unicode that is like p and function as a p?

restive void
#

!e

𝚒𝚖𝚙𝚘𝚛𝚝 𝚛𝚊𝚗𝚍𝚘𝚖
𝚙𝚛𝚒𝚗𝚝(𝚛𝚊𝚗𝚍𝚘𝚖.𝚛𝚊𝚗𝚍𝚘𝚖())
night quarryBOT
restive void
#

huh, wait a sec

#

My method of finding these is flawed..

#

Ah, no, it works. Just not with keywords.

#

!e

import 𝚛𝚊𝚗𝚍𝚘𝚖
𝚙𝚛𝚒𝚗𝚝(𝚛𝚊𝚗𝚍𝚘𝚖.𝚛𝚊𝚗𝚍𝚘𝚖())
night quarryBOT
restive void
#

But you can call eval(), er.. I mean 𝚎𝚟𝚊𝚕 of course, so you can still do anything

grave grail
#

Ah

#

Well

#

As much as I could compress, I have a converter which make any code -> only used 5 alphanumeric character including unicode substitute

#

Which obviously use eval/exec

fleet bridge
#
>>> print.__self__
builtins
``` a quick way to get `builtins` module

(`__builtins__` is not very reliable, sometimes it is a module, sometimes - a dict)
sick hound
#

Does anybody know the exact difference between type(x) and x.__class__?

fleet bridge
#

type(x) returns a real type of x - it looks up a pointer to a type in object's struct
x.__class__ is an attribute access, it acts like a regular attribute (like x.y). But it so happens that there is an attribute of that name defined in object class, so "descriptor protocol" kicks in. object.__class__ descriptor returns a type(x)

#

if __class__ is overriden in subclasses - then it will be used
if it is a descriptor - it will be triggered
if not - will be returned as is

#

x.__class__ = Y is an assignment, it also works as any other attribute assignment.
object.__class__.__set__ performs layout check, and if it is ok, it changes the type of x to Y

sick hound
fleet bridge
#

yes, exactly

#

if you are not doing anything weird - they are pretty much the same

sick hound
faint verge
#

!e

import 𝚛𝚊𝚗𝚍𝚘𝚖
𝚙𝚛𝚒𝚗𝚝(𝚛𝚊𝚗𝚍𝚘𝚖.𝚛𝚊𝚗𝚍𝚘𝚖())
night quarryBOT
quartz wave
#

interesting thing

#

code without lowercase letters

sick hound
#

Do there exist methods that are not attributes, and do they have any usefulness?

#

Another similar question - do there exist properties that are not methods?

#

3rd question - do there exist properties that are not attributes?

restive void
#

I'm not sure I understand all of the questions. You can create methods (as in: instances of the method type) that aren't attributes of anything, but it's pretty useless.

sick hound
#

if I go by definition "Attribute = Any name following a dot"

restive void
#

Properties as in @property: you can technically create properties that don't decorate functions, or decorate functions with them that aren't methods, but it's again pretty useless.

#

Same answer regarding properties that aren't attributes

sick hound
restive void
#

That's close enough, yeah.

fleet bridge
#
attributes > descriptors > methods
                         > properties
sick hound
#

I have a crazy idea

#

what if they remove commas in the next version of python

#

think about it. commas are actually not necessary

#
my_list = [1, 2, 3, 4]

could just be

my_list = [1 2 3 4]
#

also it works for functions

#
call_function(1 2 3 4)
#

want to do math for arguments? no problem

#
call_function(1 2 (3 + 4) 5)
quartz wave
sick hound
quartz wave
sick hound
#

remove commas from python change my mind

quartz wave
#

pretend i'm the python interpreter

sick hound
#

ok

#

uninstall

quartz wave
#

oh

#

so remove python > remove commas

versed eagle
#

calling an int

#

cant

sick hound
#

nah

#

the compiler can figure that out

quartz wave
sick hound
#

of course you cant call an int

versed eagle
#

then it cant

sick hound
versed eagle
#

the type is not known at parse time

grave grail
#

You need to make it so it is statically distinguishable between call_function(1, 2, (3 + 4), 5) and call_finction(1, 2(3 + 4), 5

versed eagle
#

the parser has no idea whats callable and what isnt, it has a stream of tokens

quartz wave
sick hound
versed eagle
grave grail
versed eagle
quartz wave
#

ok then

sick hound
versed eagle
quartz wave
#

also ^^^

versed eagle
#

the ast gets compiled to bytecode

night quarryBOT
#

test_sources/mixins.requite line 1

// SPDX-FileCopyrightText: 2024 Daniel Aimé Valcour <fosssweeper@gmail.com>```
grave grail
#

?

sick hound
#

see? no commas

#

did I mention that I am a coding ninja?

grave grail
#

And how does it compile?

versed eagle
#

cf. lisp

sick hound
chilly jay
#

can someone help me im in 9th grade and im starting pyhton CSP but the teacher gave me like assignments that i dont even know anyhting about, does anyone know like the best website to learn pyhton on and like a one that would actually stick in ur memory, and how do i like make my code more accurate and shorter

versed eagle
quartz wave
sick hound
#

this is valid in my langugae

versed eagle
grave grail
#

Well, I don't see a compiler 💀

quartz wave
versed eagle
#

!ot

night quarryBOT
grave grail
#

I just see a file

sick hound
#

interpreted language like python could do that easily

versed eagle
versed eagle
#

being dynamic is exactly what makes this hard

sick hound
grave grail
#

!ot Have fun with your language

night quarryBOT
versed eagle
sick hound
#

they are like

this(arg1 arg2 arg3)
quartz wave
versed eagle
quartz wave
#

parser ambiguity, impossible to resolve, period

grave grail
#

The funny exact same message

versed eagle
#

jinx! :3

sick hound
quartz wave
#

god how do you talk about parsers when you can't even parse a sentence T^T

versed eagle
#

lol

sick hound
grave grail
#

If you are serious, (idk what you should do at this point)
If you are joking, go to ot

versed eagle
#

im gonna leave the conversation now, you're being off-topic and wrong and ignoring everyone when they gently explain to you how you're wrong

grave grail
#

Go to ot

#

Thx

sick hound
sick hound
#

🫡

grave grail
#

I really want to ping a mod 💀

sick hound
#

im done

karmic pumice
#

the real ambiguity would then be with implicit str concat, but you'd just give preference to passing them as args I guess

fleet bridge
#
# works with positive integers
max = lambda a, b: (a//b*a + b//a*b) // (a//b + b//a)
min = lambda a, b: (a//b*b + b//a*a) // (a//b + b//a)

assert max(1, 1) == 1
assert max(2, 2) == 2
assert max(3, 5) == 5
assert max(5, 3) == 5


assert min(1, 1) == 1
assert min(2, 2) == 2
assert min(3, 5) == 3
assert min(5, 3) == 3
fleet bridge
#

in C it is a bit nicer because // becomes /: ```c
int max(int a, int b) { return (a/ba + b/ab) / (a/b + b/a); }

low lynx
#

me when I want to find min(0, 1)

#

I think in C it might work for negative negative as well

fleet bridge
somber raptor
#

BRUH

#

!e

result = (lambda _, __, ___, ____, _____, ______, _______, ________, _________, __________, ___________:
    getattr(
        __import__('builtins'),
        ().__class__.__eq__.__class__.__name__[:2] +
        ().__iter__().__class__.__name__[5:7]
    )(
        (lambda _, __, ___: _(_, __, ___))(
            lambda _, __, ___:
                bytes([___ % __]) + _(_, __, ___ // __) if ___ else
                (lambda: _).func_code.co_lnotab,
            _ << __________,
            (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
            - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
            __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
            << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
            ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
            __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
            << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
            _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
            (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
            _))) + (_____ << ______) + (_ << ___)
        )
    )
)(
    *(
        [len] +
        [ord] +
        [sum] +
        [int] +
        list(range(7))
    )
)

print(result)
grave grail
#

where is the execution lul

somber raptor
#

huh

#

deletid cause it kept failing

#

it looks like brainf**k

#

its my attempt on esoteric python

grave grail
#

lul

placid lynx
#

!e

night quarryBOT
#
Missing required argument

code

placid lynx
#

oops

#

!e

print((lambda _, __, ___, ____, _____: getattr(__import__(_(
    ____(
        __(NameError.__class__.__eq__.__name__[___([].__class__.__name__)])
        + ___(True.__class__.__name__) * (___(True.__class__.__name__) + ___(None.__class__.__name__)) // ___(None.__class__.__name__)
        + (___(False.__class__.__name__) - ___(NameError.__class__.__name__))
        + ___(True.__class__.__name__) + ___(None.__class__.__name__) - (___(print.__class__.__eq__.__name__) - ___(object.__class__.__name__))
    )
) + _(
    ____(
        __(NameError.__class__.__eq__.__name__[___([].__class__.__name__)])
        + ___(True.__class__.__name__) // ___(None.__class__.__name__) * ___(None.__class__.__name__)
        + (___(False.__class__.__name__) - ___(NameError.__class__.__name__))
        + (___(False.__class__.__name__) - (___(None.__class__.__name__) - (___(False.__class__.__name__) + ___(None.__class__.__name__))))
        + ___(True.__class__.__name__) + ___(None.__class__.__name__)
    )
)), 'name'))(*([chr]+[ord]+[len]+[int] + [list(range(11))])))
night quarryBOT
placid lynx
#

oh

#

old version

placid lynx
#

What was it supposed to do

#

wr_i

#

!e

def debug(chr, ord, len, int, totenlist):
    return chr(
        totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        +(totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist)[len(int.__class__.__name__)
        *len(int.__class__.__name__)]
        -totenlist[3]+(totenlist[len(int.__class__.__name__)+len(int.__class__.__name__)]*totenlist[len(int.__class__.__eq__.__name__)]-(len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)+totenlist[len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)])))+'a'+chr(totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        +(totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist)[len(int.__class__.__name__)
        *len(int.__class__.__name__)]-totenlist[4]+(totenlist[len(int.__class__.__name__)+len(int.__class__.__name__)]*totenlist[len(int.__class__.__eq__.__name__)]-(len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)+totenlist[len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)])))+'e'

print(debug(chr, ord, len, int, list(range(11))))
night quarryBOT
placid lynx
#

Sucks

#

2000 letters limit

#

!e

def debug(chr, ord, len, int, totenlist):
    return chr(
        totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        +(totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist)[len(int.__class__.__name__)
        *len(int.__class__.__name__)]
        -totenlist[len(int.__class__.__eq__.__name__)//len(int.__class__.__name__)+len(int.__class__.__eq__.__name__)//len(int.__class__.__name__)+len(int.__class__.__eq__.__name__)//len(int.__class__.__name__)]+(totenlist[len(int.__class__.__name__)+len(int.__class__.__name__)]*totenlist[len(int.__class__.__eq__.__name__)]-(len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)+totenlist[len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)])))+chr(ord('a'))+chr(totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        +(totenlist[len(int.__class__.__name__)]
        *totenlist[len(int.__class__.__name__)]
        *totenlist)[len(int.__class__.__name__)
        *len(int.__class__.__name__)]-totenlist[len(int.__class__.__name__)]+(totenlist[len(int.__class__.__name__)+len(int.__class__.__name__)]*totenlist[len(int.__class__.__eq__.__name__)]-(len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)+totenlist[len(print.__class__.__eq__.__name__)-len(int.__class__.__name__)])))+chr(ord('e'))

print(debug(chr, ord, len, int, list(range(11))))
night quarryBOT
placid lynx
night quarryBOT
placid lynx
#

sad

placid lynx
#

You provide less arguments to lambda than you actually have and wth is (lambda: _).func_code.co_lnotab

subtle spear
#

just learn js guys or rust.

#

maybe julia even

fleet bridge
subtle spear
#

or should i better say disfunctional 🤣

somber raptor
#
hello="Hello"
world="world"
def return(a):
  print(a)
return(hello, world)

!e

#

!e

night quarryBOT
#
Missing required argument

code

mortal thorn
#

I'm making a python variant of awk, pawk: https://github.com/kaddkaka/pawk

I'm thinking if there is any way to implement default print action of awk. For comparison, to print the first two lines of the input file:

  1. awk 'NR <= 2'
  2. pawk 'if NR <= 2: print(F[0])'
GitHub

awk-like python tool. Contribute to kaddkaka/pawk development by creating an account on GitHub.

#

I'm not sure if I want default action, I can't think of an elegant way to do it.

fleet bridge
#

im not sure if this will be useful, but in single compilation mode all "unused" results are being passed to sys.displayhook ||(that is how REPL displays stuff, for example)||

>>> run = lambda s: exec(compile(s, '', 'single'))
>>> import sys; sys.displayhook = lambda obj: print(f'{obj} is being displayed')
>>> run('1;2')
1 is being displayed
2 is being displayed
None is being displayed
>>> run('3 + 4 < 5')
False is being displayed
None is being displayed
mortal thorn
#

oh, so I could evaluate all unused resuts and do things with those, hmm 🤔

fleet bridge
night quarryBOT
#

main.py line 44

# Poor mans way of implementing "keywords" by catching NameError```
fleet bridge
#

you can have NEXT var that holds some special value, and if sys.displayhook gets this value you perform some "skipping" logic

#

btw NameErrors have .name attr

#

if e.name == 'NEXT': ...

night quarryBOT
#

main.py line 48

if str(e) == "name 'NEXT' is not defined":```
mortal thorn
#

Thanks for the feedback! 🙂

#

doing the displayhook is less hacky

mortal thorn
#

@fleet bridge Would you know why compile('if NR <=2: print(F[0])', '', 'single') gives syntax error?

#

I actually achieved a crash as well "core dumped" 🙀

python3
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> compile('if NR <=2: print(F[0])')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: compile() missing required argument 'filename' (pos 2)
>>> compile('if NR <=2: print(F[0])', '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: compile() missing required argument 'mode' (pos 3)
>>> compile('if NR <=2: print(F[0])', '', 'single')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "", line 1
    if NR <=2: print(F[0])
SyntaxError: invalid syntax
>>> Quit (core dumped)
fleet bridge
#

also, you can't compile several statements one after the other in single mode
(but you can wrap them in if True: ...)

mortal thorn
#

ah ok, so should use 'exec' here

quartz wave
#

(but not in single)

mortal thorn
mortal thorn
quartz wave
#

single only takes a single statement

#

oh yea-

#

it's fine i think-

mortal thorn
#

just adding \n worked with the single line if with single. But I need exec anyway for my usecase

fleet bridge
mortal thorn
#

oh 🤔

mortal thorn
quartz wave
#

exec() + compile() works

#

if you want that integration

mortal thorn
#

I'm doing compile and then exec

quartz wave
#

(and if you're executing statements single)

mortal thorn
quartz wave
#

if True:, yea-

fleet bridge
#

also, look at what is done in timeit module
they make an entire function out of user's code and then compile and call it

quartz wave
#

"if True:\n" + textwrap.indent(code, "\t")

mortal thorn
fleet bridge
#

if you combine everything into one piece of code and then just run it, you won't need messy and hacky ways of handling stuff like NEXT

#

btw NEXT is just continue

mortal thorn
#

Or rather, I want the NEXT in the user script to the next record in pawk's for loop (for line_no, line in enumerate(lines):

#

But I would have to do some fixups to the handling of BEGIN and NR

#

But still, it seems a bit backwards since I want the displayhook to only act on the user code

fleet bridge
#

you can parse user code, and then unparse it, wrapping expression statements in some function

mortal thorn
#

this is turning into a chore more than a hack 🤓

#

Not sure I like it, yet. The idea has to mature. Is it nice to parse python code?

karmic pumice
#

!d ast.parse

night quarryBOT
#

ast.parse(source, filename='<unknown>', mode='exec', *, type_comments=False, feature_version=None)```
Parse the source into an AST node. Equivalent to `compile(source, filename, mode, ast.PyCF_ONLY_AST)`.

If `type_comments=True` is given, the parser is modified to check and return type comments as specified by [**PEP 484**](https://peps.python.org/pep-0484/) and [**PEP 526**](https://peps.python.org/pep-0526/). This is equivalent to adding [`ast.PyCF_TYPE_COMMENTS`](https://docs.python.org/3/library/ast.html#ast.PyCF_TYPE_COMMENTS) to the flags passed to [`compile()`](https://docs.python.org/3/library/functions.html#compile). This will report syntax errors for misplaced type comments. Without this flag, type comments will be ignored, and the `type_comment` field on selected AST nodes will always be `None`. In addition, the locations of `# type: ignore` comments will be returned as the `type_ignores` attribute of [`Module`](https://docs.python.org/3/library/ast.html#ast.Module) (otherwise it is always an empty list).
fleet bridge
quartz wave
#

ah wait hold on

#

ast.Expr yea

#

ast.Expression for the eval() version

mortal thorn
#

I have not mixtured with this, will be an interesting exercise

#

And not too late 😅

scarlet bone
#
while (a := globals().setdefault("a", 5) - 1) >= 0 and (print("Correct") if 5 == (b := int(input("Give me a nr: "))) else print(f"Wrong {a} tries left")) != 5:
    if b == 5: break
vast wave
tranquil yarrow
bright valve
tranquil yarrow
#

"just" is an underappreciation

#

i'm literally running a custom iterator to keep the loop alive

#

and again, this is entirely one expression

#

otherwise i wouldn't be able to "use and instead of newline"

bright valve
#

I just meant using ands and () feels like using ; instead of newlines

tranquil yarrow
#

why?

digital dirge
#

A http server that serves from a static directory is really not hard in one line 😄

tranquil yarrow
digital dirge
#

and why wouldn't you 😄

tranquil yarrow
#

i haven't prevented that in the readme, so it's a valid point, thanks

#

the new requirement: make it async

#

(must run under async event loop)

#

and not reusing the logic from http.server

#

(no run_in_executor etc.)

digital dirge
tranquil yarrow
fleet bridge
#

json parser should not be that hard
just take json from stdlib and translate it into one line

tranquil yarrow
#

waiting for suggestions lol

tranquil yarrow
#

i should also mention that by one line i mean "one expression statement"

#

which is not the same as one line

#

import __hello__ is also one line

#

ah, and tests--we want to use pytest and fit all tests for a module in one expression statement

fleet bridge
#

You are given a string of digits.
Your task is to split it into a strictly increasing sequence of numbers (in all possible ways).

141312 - input
possible splits:
141312
1 41312
1 41 312
14 1312
141 312
(I'm not sure that that is all possible ways :)
mortal thorn
#

1 1 1 2 3 4

#

lots of more ways to split, right?

fleet bridge
#

you also rearranged numbers
if you can rearrange them, then increasing constraint doesn't really make any sense

tranquil yarrow
fleet bridge
#

yes, but most of them do not form an increasing sequence of numbers

tranquil yarrow
#

oh, i haven't read that part

#

thanks

tranquil yarrow
#

something missing?

fleet bridge
#

feels right

mortal thorn
#

12 13 14? Oh you are not allowed to rearrange the parts after splitting?

#

I see

mortal thorn
# fleet bridge you can have `NEXT` var that holds some special value, and if `sys.displayhook` ...

I'm not sure how the skipping logic could actually work because I would need to break and redirect the program flow when NEXT is detected. Is it possible?

Also considering using continue instead of NEXT (not sure which one is preferable from user perspective), but naive use of continue currently and unsurprisingly leads to SyntaxError: 'continue' not properly in loop . So trying to more properly parse and combine the user script with pawk record loop might be next step.

fleet bridge
#

user could type NEXT but you can replace it with continue to make it do something useful

mortal thorn
#

So I made a bunch of smaller modifications to the code, and currently the inner loop looks like this:

def process_file(program, lines, last_file, _locals):
    """Iterate over multiline text input and process with user program"""
    for line_no, line in enumerate(lines):
        last_line = line_no == len(lines) - 1
        _locals["END"] = last_file and last_line
        _locals["FNR"] = line_no + 1

        # Full line as f[0] and the rest of columns start from f[1]
        f = [line, *(intify(w) for w in line.split())]
        _locals["F"] = f
        _locals["NF"] = len(f)

        # Poor mans way of implementing "keywords" by catching NameError
        try:
            exec(program, {}, _locals)  # pylint: disable=exec-used
        except NameError as e:
            if e.name == "NEXT":
                pass
            else:
                raise

        _locals["BEGIN"] = False
        _locals["NR"]    += 1

I would want insert the user code at the # Poor comment, but still preferably keep this code mostly intact to get syntax highlighting and such

digital dirge
#

What are you doing actually? pithink

mortal thorn
#

pawk!

digital dirge
#

I actually don't know awk 😄

bronze yarrow
#

Hi

digital dirge
#

I read the readme tho, looks cool!

mortal thorn
#

It's really cool and a very useful tool! From the preface of "The AWK programming language"

x PREFACE
Awk is a programming language that makes it possible to handle simple computations
with short programs, often only one or two lines long. An Awk program is a sequence of pat-
terns and actions that specify what to look for in the input data and what to do when it’s
found. Awk searches a set of files that contain text (but not non-text formats like Word docu-
ments, spreadsheets, PDFs and so on) for lines that match any of the patterns; when a match-
ing line is found, the corresponding action is performed. A pattern can select lines by combi-
nations of regular expressions and comparison operations on strings, numbers, fields, vari-
ables, and array elements. Actions may perform arbitrary processing on selected lines; the
action language looks like C but there are no declarations, and strings and numbers are built-
in data types.
Awk scans text input files and splits each input line into fields automatically. Because so
many things are automatic — input, field splitting, storage management, initialization — Awk
programs are usually much shorter than they would be in a more conventional language.
Thus one common use of Awk is for the kind of data manipulation suggested above. Pro-
grams, a line or two long, are composed at the keyboard, run once, then discarded. In effect,
Awk is a general-purpose programmable tool that can replace a host of specialized tools or
programs.

digital dirge
#

I see, cool stuff pithink

#

And what's that about inserting the user code?

mortal thorn
#

So I want a user of awk to be able to run for example pawk input_file -t 'if F[2] > 10: print(F[0])'
on an input such as:

kaddkaka 5
Trapture 9000

The output from running the command would be:

Trapture 9000

Here the 'if F[2] > 10: print(F[0])' part is the user program that I currently run by calling exec in the pawk src code.

digital dirge
#

What's the issue with exec?

mortal thorn
#

It would be nice if a continue in the user code would skip to the next iteration of the for loop. Then I got get rid of the hacky try; except: NameError

earnest wing
mortal thorn
earnest wing
#

bqn :)

#

recursive algos are kind of sucky with it though

mortal thorn
earnest wing
#

I first wrote the concept in python and then translated manually 😄

mortal thorn
#

Uff 😅

digital dirge
versed eagle
# sick hound Make a weird function that checks if all ints in a list are ones ```py def allOn...

old thing but here you go

@__import__("fishhook").hook(object)
def __matmul__ (f, g): return lambda *a, **k: f(g(*a, **k))
prt = __import__("functools").partial
c = type("curried", (), dict(
    __init__  =lambda s, f: vars(s).update(f=f, a=[], k={}),
    __call__  =lambda s, *a, **k: s.a.extend(a) or s.k.update(k) or s,
    __invert__=lambda s: prt(s.f, *s.a, **s.k)
))

all_ones = all @ ~c(map)(1 .__eq__)
fleet bridge
#

there is infinite number of ways to write hello world

#

if you scroll this channel far enough you will find several dozens of hello worlds

stiff glen
fleet bridge
night quarryBOT
fleet bridge
#

that was the first idea that came to mind: check all possible ways to split the string and take only good ones
enumeration is done by generating integers from 0 to 2**n in binary, and then interleaving it with input string

fleet lintel
#

I was doing something else and stumbled across something pretty silly: It's fairly easy to convert between bases using just repeated regex application, as long as you go through base 1 :) https://paste.pythondiscord.com/65LA

fleet bridge
#

congrats, you invented Markov algorithms

#

In theoretical computer science, a Markov algorithm is a string rewriting system that uses grammar-like rules to operate on strings of symbols. Markov algorithms have been shown to be Turing-complete, which means that they are suitable as a general model of computation and can represent any mathematical expression from its simple notation. Marko...

digital dirge
#

I actually love when that happens because it confirms my thoughts were good, I was just not the first person to come up with it 😄

hybrid trail
#

the inner loop could probably be golfed some more

hybrid trail
#

142 with ||interleaving||
||python B=len(A:=input())-1 for C in range(2**B):eval('<'.join(map(str,E:=eval("".join(a+"_,"[int(b)]for a,b in zip(A,f'{C:0{B}b}1'))))))and print(*E)||

#

I really thought it would be way shorter 🤔

quartz wave
#

126 ||```py
B=len(A:=input())-1;C=2**B
while C:C-=1;*E,=eval("".join(a+"_,"[b>'0']for a,b in zip(A,f'{C:{B}b}1')));E==sorted(E)!=print(*E)

hybrid trail
#

very clever

earnest snow
night quarryBOT
#

json_parser_golf.py line 35

p=lambda s,j=''.join:({}['Extra Data Remaining']if[r:=p(I:=[*s][::-1])]and j(I).rstrip()else r)if isinstance(s,str)else float(i)if(S:=lambda s:s.__setitem__(slice(None),j(s).rstrip())or s)(s)and(i:=j(iter(lambda:s.pop()if s and s[-1]in'-+0123456789.eE'else 0,0)))else{'true':True,'false':False,'null':None}[c]if(c:=j(iter(lambda:s.pop()if s and s[-1].isalpha()else 0,0)))else[list,dict,j][(d:=ord(s.pop())//2%3)](iter(lambda:(s.pop()and p)if S(s)[-1]==(t:=']}"'[d])else[k if[k:=p(s)if d<2else s.pop()]and d==0else((k if isinstance(k,str)else{}['Keys must be Strings'],p(s))if d==1and(S(s),{}['Invalid Seperator']if s[-1]!=':'else s.pop())else(k if k!='\\'else('\b\f\n\r\t'+q)[('bfnrt'+q).index(q)]if(q:=s.pop())!='u'else chr(int(j(s.pop()for()in[()]*4),16)))if d==2else p),(s.pop()if l!=t else 0)if d<2and(l:=S(s)[-1])in','+t else 0if d==2else{}['Missing Seperator']][0],p))```
rugged sparrow
#

Pretty sure it mostly works?

karmic pumice
#

doesnt handle infinity and nan but yeah this is kinda based
ill try to make a.. oneliner recursive descent parser

rugged sparrow
#

Inf and NaN aren't part of the json spec afaik

mortal thorn
karmic pumice
fleet lintel
# karmic pumice is there a reason why does python's json handle them?

Because it's standard/for consistency I guess?
https://docs.python.org/3/library/json.html#json.JSONEncoder

If allow_nan is true (the default), then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
https://docs.python.org/3/library/json.html#standard-compliance-and-interoperability
This module does not comply with the RFC in a strict fashion, implementing some extensions that are valid JavaScript but not valid JSON. In particular:

  • Infinite and NaN number values are accepted and output;
  • Repeated names within an object are accepted, and only the value of the last name-value pair is used.
    Since the RFC permits RFC-compliant parsers to accept input texts that are not RFC-compliant, this module’s deserializer is technically RFC-compliant under default settings.
twin roost
#

Is it possible for python bytecode compiler to add a frozenset in co_consts? or from iterables it can only add tuples?

#
f = lambda x: frozenset((5,2,5))
dis.dis(f)
  1           0 RESUME                   0
              2 LOAD_GLOBAL              1 (NULL + frozenset)
             14 LOAD_CONST               1 ((5, 2, 5))
             16 PRECALL                  1
             20 CALL                     1
             30 RETURN_VALUE
f.__code__
<code object <lambda> at 0x000001CCE7E94110, file "<stdin>", line 1>
f.__code__.co_consts
(None, (5, 2, 5))
#

oh, stop, it adds usual sets as frozen by default

>>> f = lambda x: {5,2,5}
>>> dis.dis(f)
  1           0 RESUME                   0
              2 BUILD_SET                0
              4 LOAD_CONST               1 (frozenset({2, 5}))
              6 SET_UPDATE               1
              8 RETURN_VALUE
restive void
#

Sort of, yeah. But then immediately turns it into a regular set with SET_UPDATE

twin roost
#

but atleast it doesn't recalculate the hashes I guess

restive void
#

!e but you can put other things in co_consts:

def foo(): return 1, 2, 3
foo.__code__ = foo.__code__.replace(co_consts=(None, frozenset((1, 2, 3))))
print(foo())
night quarryBOT
restive void
twin roost
restive void
#

Ah, true

twin roost
#

maybe there is some optimization mechanism "not to copy it completely until it's actually get mutated"

restive void
#

Then I guess SET_UPDATE probably makes a copy if it operates on a frozenset.

fleet bridge
potent comet
#

It doesn't set a mutability flag, the opcodes are the equivalent of doing:

result = set()
result.update(the_constant)

But set.update() has an optimisation, if self is empty and the provided value is a set/frozenset, then it just copies the hash table over.

fleet bridge
restive void
#

Ohh, I didn't see the BUILD_SET before

fleet bridge
#

I'm pretty sure frozensets and sets have different underlying structure, because one of them can grow, and other one is constant

quartz wave
#

that's it

#

in the object structure the only different things between a frozenset() and a set() are the .ob_base (basically .__class__ in top-level) and .hash fields

fleet bridge
#

interesting...

narrow drift
#

Does anyone know anything about OCR for batches of webtoon images for each episode using tesseract. I already have a python script that runs fine but nothing is produced in terms of text extraction.

#

Idk where to ask this problem of mine.

fleet bridge
narrow drift
#

Alright thanks for letting me know.

earnest wing
#

!e ```py
print(chr(sum(range(ord(min(str(not())))))))

night quarryBOT
subtle viper
grave grail
#

?

fallow leaf
#

They didn't

vast wave
night quarryBOT
gleaming quiver
#

!e ```py
0xf or (lambda a, b: a + b) in [1, 2, 3, 4, 5]

night quarryBOT
sick hound
#

!e

import math
def m(n):return((n<<1)+(n<<(n%2+2)))^(n>>1)
a,b,c,d=0xea1dbc39,0x73ccab33,0x4f85d342,0x166454f0
e,f,g,h=0xde56059d28c30d09,0xf15340a75e9c480d,0x96d90450f0186553,0x37ec2bfd9680cf43
z,y=0x0005fe3126d76bff,0x0009d9f0f3a7d217+634418226003968
def k(n):print(n.to_bytes(12).decode())
for i in range(4):
    for j in range(a%11):
        a,b,c,d=b,c,d,a;a=m(a+b)+c;b=m(b+c)-d;c=m(c+d)+a;d=m(d+a)-b
        e-=m(e)%(a&0xffffffff);f^=e;g^=(e+d)%0xffffffff;h=(h+a)%0xffffffffffffffff
        a=a*b+c;z+=(a+b+d+e)%19
a=int((abs(a+b-c+d)%(1<<96))*(2/3));b=abs(b)%0xffffffff;z+=15.32
c=abs(c)%(b+0x003fffff);d=abs(d)%(c+0x0100b654);a=int(a+(b*c*d)**1.0331355)
for i in range(6):b,c,d=m(b),m(b+c),m(b+c+d)
k(((((((a^(b*c//d))-int(math.sqrt(e*f+c))<<7)>>20)<<20)-int(z**2))^(int(z)>>1)^y)+0x000481fffc000000)
night quarryBOT
grave grail
#

Nice

night quarryBOT
#

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

somber raptor
#

a,b=0,1
while a<9e5:print(a);a,b=b,a+b
anyone know an intresting way to replace the while loop or 9e5 or the print function

fleet bridge
#

!e ```py
a,b=0,1
exec('print(a);a,b=b,a+b;'*10)

night quarryBOT
somber raptor
#

okk

#

now i need it touhh

#

have it 36 bytes

#

which is the hard part

#
d=lambda p:chr(ord('A')+len(p)-1)if 1<=len(p)<=26 else'' 
m=lambda e:''.join(d(s)if s else' 'for s in e.split(' ')) 
e="............. ..... ............ ............ ............... , ....................... ............... .................. ............ ...." 
print(f"Encoded message:{e}")
print(f"Decoded message:{m(e)}")
night quarryBOT
#
Missing required argument

code

somber raptor
#

!eval [python_version] <code, ...>

night quarryBOT
night quarryBOT
# somber raptor !eval [python_version]

: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 |     [python_version]
004 |      ^^^^^^^^^^^^^^
005 | NameError: name 'python_version' is not defined
somber raptor
#

broo

weak imp
#

its like

#

!eval

print('a')
night quarryBOT
weak imp
somber raptor
#

!eval 3

d=lambda p:chr(ord('A')+len(p)-1)if 1<=len(p)<=26 else'' 
m=lambda e:''.join(d(s)if s else' 'for s in e.split(' ')) 
e="............. ..... ............ ............ ............... , ....................... ............... .................. ............ ...." 
print(f"Encoded message:{e}")
print(f"Decoded message:{m(e)}")
night quarryBOT
somber raptor
#

its close

weak imp
#

uwu

somber raptor
#

wtf

#

whys it not working

#

CHALLENGE: print hello world with the digits of sqrt(2)

fleet bridge
somber raptor
#

uh

#

i gues

#

i kinda meant to use the digits to print hello world

fleet bridge
night quarryBOT
#
Missing required argument

code

somber raptor
#

!eval 3

b64d=lambda e:bytes(int24>>i*8&0xFF for i in range(3,-1,-1)if e[-i]!='='for int24 in(int(q,16)<<i*6|int(q,16)<<(i-1)*6|int(q,16)<<(i-2)*6|int(q,16)<<(i-3)*6for q in(hex(b64c.index(e[i]))[2:]for i in range(0,len(e),4))))
b64c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
print(b64d("SGVsbG8gd29ybGQh"))
dusk quartz
#

wat the fuck is this 😭

#

that looks hard as fuck

#

is this encoding

karmic pumice
#

!e

(lambda f: (t * 1).from_address(id(int) + 88).__setitem__(0, f) or (print(1) or f))((t := (c := __import__("ctypes")).CFUNCTYPE(c.py_object, c.py_object))(lambda _: "hi!"))
night quarryBOT
lunar moon
#

i remember i saw esoteric code which looked beautiful before

#

the whole program looked like it was an ascii art

#

anyone knows what i am saying

grave grail
#

Donut?

grave grail
# dusk quartz is this encoding

That's decoding, you can search about base64, it is essential the best way to send binary data in non-binary accepting field

#

(That is not quite precise:
So:
def non-binary accepting field: a field that doesn't accept special character that usually ain't printable/provide a specific meaning to the computer/software in a general practice, or hardly convey any readable meaning to human

astral steppe
astral steppe
#

and the cookie clicker that wont work but i made everything else

fleet bridge
#

that is not an Operating System

#

also, it is off topic to this channel

subtle viper
astral steppe
#

thingy

fleet bridge
#

that is not at all what an Operating System is supposed to do
so it is a concept for a set of different tools, but not an OS concept

astral steppe
#

im just a deadbeat loser programmer

astral steppe
#

anyways im heading to bed

#

im tired

digital dirge
#

Oof

#

Not a very esoteric mindset

timber bison
#

Damn @fleet bridge why u have to rip him to shreds like that

lunar moon
#

thanks

near gust
#

i proved that python but restricted to a single expression, calls to builtin functions, the not keyword, and tuple creation is turing-complete.

(also no reflection/arbitrary code execution methods)

#

This subset of python is Turing-Complete by substitution with Cyclic Tag:

data string is encoded as follows:
0 => not()
1 => len(((),()))
program is encoded as follows:
; => list(map(next,map(iter,map(reversed,filter(min,enumerate(("previous code")))))))
0 => sum(list((list(map(next,map(iter,zip(list((not(),)),iter(int,sum(range(next(iter("previous code"))))))))),)),"previous code")
1 => sum(list((list(map(next,map(iter,zip(list((len(((),())),)),iter(int,sum(range(next(iter("previous code"))))))))),)),"previous code")

Substitution instructions:
Start with the program as a tuple containing the encoded data string. Then replace it with `list({said tuple})`. For each instruction, replace "previous code", with the code from the previous iteration
near gust
night quarryBOT
hybrid trail
#

very similar to the a-z() discussions going on earlier

near gust
#

hmmm

hybrid trail
near gust
#

yes, in fact

#

i found that on the rust discord and then i sent it to my uni server. We then figured out that we could create any number. And then i decided i would figure out if it was turing-complete

#

one of us is working on an optimal solution finder for any given number

flint hollow
#

does someone need to post the jurassic park gif about being too busy doing something to evaluate whether the thing should be done at all

near gust
#

i was bored and had time to waste

hybrid trail
near gust
#

yeah... i think they ended up giving up

#

zip([0],iter(int, something_that_is_zero_or_one)) my beloved

#

it's funny how i used iter as the main conditional, while filter is only used here to delete the first element

near gust
versed eagle
#

sum(map(ord,str(help)))

#

but yeah in general comprehensions make things easy

near gust
#

comprehensions could be used duplicate lists and make those 0s and 1s above much easier

#

without needing to paste the code in 2 spots and making it exponentially grow

#

i spent like 2 hours trying to figure out how not to have that exponential growth but gave up

versed eagle
#

the condition inside the iter can be stored cant it

near gust
#

if only we had a way to make lambda: x

#

i should probably sleep instead of thinking about this

versed eagle
versed eagle
quartz wave
near gust
versed eagle
#

or some other thing you can assign attributes to

near gust
#

after doing this challenge i feel like python's builtins are so arbitrary and random

versed eagle
#

these are not typically seen under the realm of reflection i think
but something like hasattr is

karmic pumice
#

getattr with a name that is not constant does feel like reflection to me

near gust
#

yeah, i come from a mostly statically typed background

versed eagle
#

str()

karmic pumice
#

i see, i didn't read the context, just "is getattr reflection"

versed eagle
# versed eagle the name is constant though

more generally, as long as the variable name isnt being dynamically determined at runtime i would say its not reflective
e.g. using both getattr(x, str(1)) and getattr(x, str(2)) is still not reflective i would say

versed eagle
#

the general case of getattr is reflective definitely

near gust
#

when did python remove the ability to sum strings

versed eagle
near gust
#

oh

versed eagle
#

back from when cpython used svn instead of git

jolly rock
quartz wave
#

as in, python 2.3 alongside the addition of sum()

near gust
#

if i could sum strings, i could've made this a lot more concise

near gust
#

and format could've been used for ;

#

but I'm kinda glad i didn't go that route

#

using 2 arg iter made this really elegant

versed eagle
#

it only checks the type of start

near gust
#

my original plan for proving turing-completeness was fucking around with __code__ and implementing SKI calculus

quartz wave
#

!e ```py
print(sum(["a", "b", "c"], start=type('',(),{'add':lambda _,x:x})()))

night quarryBOT
quartz wave
#

..well i'll be damned

near gust
#

yeah, but the real question is how i would get the lambda

versed eagle
near gust
#

yeah that's why i didn't end up doing it

quartz wave
#

but still, sums="".join

versed eagle
quartz wave
#

a lambda is a function

versed eagle
#

you can instantiate your own functions

quartz wave
#

and a function is

near gust
#

can't use . or imports for this

versed eagle
#

no imports is interesting though

#

do you not have __import__

#

its a builtin

near gust
#

i didn't allow it because itertools would make ct trivial

versed eagle
#

mm fair

near gust
#

and because it started with __ and didn't look like the rest

quartz wave
#

there's type(__loader__.get_code.__func__) for types.FunctionType, type(__loader__.get_code.__func__.__code__) for types.CodeType

#

that is if you can use those :p

versed eagle
#

question: you say only builtin functions, do you mean only builtin functions + types?

near gust
#

could also do some fuckery with dir maybe

#

but that might be a stretch

versed eagle
#

dir is reflective probably

near gust
#

dir always returns in alphabetical order

quartz wave
#

characterization ala unicode codepoint of the summation of the first numbers starting from zero with a length of the ordinal of the minimal character in the string produced by the boolean inverse of an empty tuple constant

night quarryBOT
#

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

001 |   File "/home/main.py", line 1
002 |     print(getattr(next(iter(dir(iter)), help))
003 |          ^
004 | SyntaxError: '(' was never closed
near gust
#

!e

print(type(getattr(exit,next(iter(dir(iter))))))
night quarryBOT
near gust
#

we can get the method type

#

and that means we can get lambda: x i think

#

type(getattr(exit,next(iter(dir(iter)))))(iter, x) gives us lambda: iter(x)

#
list(map(list,map(next,map(reversed,zip(((),()),iter(type(getattr(exit,next(iter(dir(iter)))))(iter,x),()))))))

gives us [x, x]

near gust
#

i think i'll try to make ski calculus

solid kernel
#
import math
num = 42
is_even = True if int(int(bin(num*1)[2:],2)*69/(35+34))**(1 if 2*3.14/7.28 == 1 else max(0,-3,-7,1,83**0.00001))//num*(num-1+1)+((3.14+2.71828)*0) == num and not str(num/2).endswith(".5") or bool(round(math.exp(1.0328)-math.sin(1.0328**2)+1.0328**2-3)) else False
near gust
#

!e

print(type(getattr(exit,next(iter(dir(iter)))))(type(getattr(exit,next(iter(dir(iter))))),type(getattr(exit,next(iter(dir(iter))))))(lambda x,y,z:x+y+z)(1)(2)(3)(4))
night quarryBOT
# near gust !e ```py print(type(getattr(exit,next(iter(dir(iter)))))(type(getattr(exit,next(...

: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 |     type(getattr(exit,next(iter(dir(iter)))))(type(getattr(exit,next(iter(dir(iter))))),type(getattr(exit,next(iter(dir(iter))))))(lambda x,y,z:x+y+z)(1)(2)(3)
004 |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
005 | TypeError: <lambda>() missing 1 required positional argument: 'z'
near gust
#

oops

#

oh wait that only works for 2 or less arguments

#

!e

print(type(getattr(exit,next(iter(dir(iter)))))(type(getattr(exit,next(iter(dir(iter))))),type(getattr(exit,next(iter(dir(iter))))))(lambda x,y:x+y)(1)(2))
night quarryBOT
near gust
#

currying my beloved

#

type(getattr(exit,next(iter(dir(iter)))))(sum,()) is the I combinator. The other combinators are much more difficult to implement

#

every single time i tried to implement the K or S combinators, I ended up wanting a C combinator

#

the closest I got to a K combinator was this, but it broke the rules

lambda x: lambda y: type(getattr(exit,next(iter(dir(iter)))))(next,type(getattr(exit,next(iter(dir(iter)))))(type(getattr(exit,next(iter(dir(iter))))),type(getattr(exit,next(iter(dir(iter))))))(iter)(type(getattr(exit,next(iter(dir(iter)))))(type(getattr(exit,next(iter(dir(iter)))))(sum,()),x))(not y))()

or more compactly:

lambda x,y:bind(next,curry(iter)(bind(I,x))(not y))()
near gust
#

because yeah that is functionally an identity even if it doesn't return the same exact object

wraith slate
#

print(chr(sum(range(ord(min(str(not())))))))

empty coyote
#

!e
print(chr(sum(range(ord(min(str(not())))))))

night quarryBOT
fleet bridge
#

you are a week too late with this one

unreal echo
#

Amogud

near gust
#

I'm so close to a K combinator. Arguments are passed in reverse order (via currying). I just need a way to get the string __init__. Also I found a nicer way to get __call__ as a str

type(str(),(),dict((("__init__",print),(min(dir(iter)),type(getattr(exit,min(dir(iter))))(sum,())))))(y)(x)
#

yes, I'm using print as a __init__. print has the unique property of taking a *args while also returning None. This is the only way I could think of to get a 2 or more argument function that returns None with these restrictions

#

you can get set.__and__ with getattr(set,min(dir(set)))

near gust
#

you can get __eq__ with next(reversed(next(reversed(next(reversed(next(reversed(min(filter(all,enumerate(filter(all,enumerate(filter(all,enumerate(filter(all,enumerate(dir(object()))))))))))))))))))

near gust
inland axle
#

@near gust have you considered the name class Lily(asyncio.tasks._PyTask):?

restive void
#

all python functions either return or error (or infinitely loop)

Is it possible to make "alternate returns", like in the bad old days? I.e. a function that returns to a completely different callstack.

fleet bridge
#

where can I read about that? how is this called?

#

sounds gross

versed eagle
#

it would be fairly complicated though

restive void
# fleet bridge where can I read about that? how is this called?

It's hard to find something to link to, but before structured programming, with untamed goto (think longjmp).
This is apparently where the "single entry, single exit" rule comes from: it didn't mean "don't have several return statements", but "don't have returns that return to different places" (and also "don't enter the function anywhere other than at the beginning").

fleet bridge
#

that is so unusual and pretty hard to imagine...

quartz wave
#

but it's plausible

night quarryBOT
#

Python/bytecodes.c line 2680

is_meth = 1;  // For consistenct; it's dead, though```
quartz wave
#

okay i found out how

#

!e @restive void ```py
from ctypes import POINTER, c_void_p
from sys import _getframe as _gf

objhead_size = object.basicsize
ptr_size = tuple.itemsize

https://github.com/python/cpython/blob/3.12/Include/internal/pycore_frame.h

offset of f_frame from the base of struct _frame (A.K.A. PyFrameObject)

interpframe_off = objhead_size + ptr_size

def delete_frame(frame=None, depth=1):
if frame is None:
frame = _gf(1)
if depth < 1:
raise ValueError("depth must be 1 or above")
prev = cur = None
for _ in range(depth + 1):
prev = cur
cur = frame
frame = frame.f_back
if frame is None:
raise ValueError("depth exceeds top frame's child frame")
POINTER(c_void_p * 2).from_address(id(prev) + interpframe_off).contents[1] = c_void_p.from_address(id(frame) + interpframe_off)

def f():
abc()

def abc():
delete_frame()
return 7

print(f())

night quarryBOT
quartz wave
#

teehee~ avoiding errors :p ```pycon

def stopper():
... x = f()
... raise ValueError(x)
...
def f():
... return 2 + abc()
...
def abc():
... delete_frame(depth=2)
... return 7
...
stopper()
9

versed eagle
#

so cool

rugged sparrow
#

or at least it could when i wrote it