#esoteric-python

1 messages ยท Page 105 of 1

wanton tundra
#

at some point some1 gonna reinvent python2 within python3

neat verge
#

yeup

floral meteor
#

!e ```py
....class.class("stdout",(),{'le':lambda self,o:[lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':o}))})() <= [lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':11*'%c'%(lambdaa:([+t+100for t in a],))(-28,--1,--8,--8,11,-68,-13,11,14,--8,+0)}))[0]

night quarryBOT
#

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

001 | Hello World
002 | Hello World
wanton tundra
#

is it possible to make above print N times instead of 2

terse mortar
#

What made you feel the need to use shitty string formatting

#

It was bad enough before

wanton tundra
floral meteor
#

!e ```py
def print_n_times(n):n and(....class.class("stdout",(),{'le':lambda self,o:[lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':o}))})() <= [lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':12*'%c'%(lambdaa:([+t+100for t in a],))(-28,--1,--8,--8,11,-68,-13,11,14,--8,+0,-90)}))[0]*(n-1))
print_n_times(5)

night quarryBOT
#

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

001 | Hello World
002 | 
003 | Hello World
004 | Hello World
005 | Hello World
006 | Hello World
wanton tundra
#

a random blank line

#

huh

#

thats odd

floral meteor
#

!e ```py
def print_n_times(n):n and(....class.class("stdout",(),{'le':lambda self,o:[lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':o}))})() <= [lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':12*'%c'%(lambdaa:([+t+100for t in a],))(-28,--1,--8,--8,11,-68,-13,11,14,--8,+0,-90)}))[0]*(n-1))
print_n_times(1)

night quarryBOT
#

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

Hello World
floral meteor
#

!e ```py
def print_n_times(n):n and(....class.class("stdout",(),{'le':lambda self,o:[lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':o}))})() <= [lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':12*'%c'%(lambdaa:([+t+100for t in a],))(-28,--1,--8,--8,11,-68,-13,11,14,--8,+0,-90)}))[0]*(n-1))
print_n_times(2)

night quarryBOT
#

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

001 | Hello World
002 | 
003 | Hello World
floral meteor
#

!e ....__class__.__class__("stdout",(),{'__le__':lambda self,o:[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda _:_._)(....__class__.__class__(().__str__().__class__(),().__class__(),{'_':o}))})()

#

!e ....class.class("stdout",(),{'le':lambda self,o:[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':o}))})() <= "Hello World"

night quarryBOT
#

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

Hello World
floral meteor
#

!e ```py
stdout=....class.class("stdout",(),{'le':lambda self,o:[lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':o}))})()
disp = lambda d:[lambda
d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':d}))[0]
stdout <= disp("Hello World")

night quarryBOT
#

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

001 | Hello World
002 | Hello World
floral meteor
#

aha I like this function I can print a thing as I use it

wanton tundra
#

im just trying to understand 1% of it

floral meteor
#

!e ```py
disp = lambda d:[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':d}))[0]
disp(disp(disp(disp(disp(disp("yeet"))))))

night quarryBOT
#

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

001 | yeet
002 | yeet
003 | yeet
004 | yeet
005 | yeet
006 | yeet
wanton tundra
#

so the number of times it prints is amount of recursive calls

#

thats a fun function

floral meteor
#

!e ```py
disp = lambda d:[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':d}))[0]
def self(n=0):
from sys import _getframe as e
f=lambda:None
f.code=e(n+1).f_code
return f
print_n_times=lambda n,s:n and self()(n-1,disp(s))
[print_n_times(3,this)for this in ['yeet','',"Hello World!"]]

night quarryBOT
#

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

001 | yeet
002 | yeet
003 | yeet
004 | 
005 | 
006 | 
007 | Hello World!
008 | Hello World!
009 | Hello World!
floral meteor
#

there

#

I summoned the self reference from the land of the cursed

#

oh wait that's here

#

๐Ÿ˜†

wanton tundra
#

!e

disp = lambda d:[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda _:_._)(....__class__.__class__(().__str__().__class__(),().__class__(),{'_':d}))[0]
def self(n=0):
  from sys import _getframe as e
  f=lambda:None
  f.__code__=e(n+1).f_code
  return f
print_n_times=lambda n,s:n and self()(n-1,disp(s))
[print_n_times(n,this)for this,n in zip(['yeet','',"Hello World!"], [3,1,3])]
night quarryBOT
#

@wanton tundra :white_check_mark: Your eval job has completed with return code 0.

001 | yeet
002 | yeet
003 | yeet
004 | 
005 | Hello World!
006 | Hello World!
007 | Hello World!
wanton tundra
#

this works as well

#

cool

#

@floral meteor this a really fun function

floral meteor
#

ty

#

and you see print isn't even called directly,it's passed as an argument to a decorator combiner to decorate a class

#

so the double lambda makes the print print the lambda next to it with the class after that as its argument, and the class has it's _ attribute set to the input from the lambda d: and the zeroeth element is taken because for some reason it returns [<d>, None]

#

[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()] - decorator combiner

#

(print,lambda _:_._) - arguments to the above

#

(....__class__.__class__(().__str__().__class__(),().__class__(),{'_':d})) - argument to the second element of above

#

as for the self reference function you could make your own _getframe using error handling and traceback

#

!e ```py
disp = lambda d:[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':d}))[0]
stdout=....class.class("stdout",(),{'le':lambda self,o:disp(o)})()
def self(n=0):
from sys import _getframe as e
f=lambda:None
f.code=e(n+1).f_code
return f
print_n_times=lambda n,s:n and self()(n-1,stdout <= s)
[print_n_times(n,this)for this,n in zip(['yeet','',"Hello World!"], [3,1,3])]

wanton tundra
#

really fun stuff

night quarryBOT
#

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

001 | yeet
002 | yeet
003 | yeet
004 | 
005 | Hello World!
006 | Hello World!
007 | Hello World!
floral meteor
#

there

#

"s goes to stdout" but is also returned to the function

wanton tundra
#

i was gonna make it a dictionary and zip keys and values but i realized i coud type less if i just did 2 lists

floral meteor
#

lel

#

you coulda just done dict.items()

#

and boom

wanton tundra
#

i always forget thats a thing

floral meteor
#

!e ```py
disp = lambda d:[lambda*d:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':d}))[0]
stdout=....class.class("stdout",(),{'le':lambda self,o:disp(o)})()
def self(n=0):from sys import _getframe as e;(f:=lambda:None).code=e(n+1).f_code;return f
print_n_times=lambda n,s:n and self()(n-1,stdout <= s)
[print_n_times(n,this)for this,n in {'yeet':3,'':1,'Hello World!':3}.items()]

night quarryBOT
#

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

001 | yeet
002 | yeet
003 | yeet
004 | 
005 | Hello World!
006 | Hello World!
007 | Hello World!
wanton tundra
#

i wonder if there is a way to navigate throught _builtins_ stuff to create dictionary like that and make this even more complicated

floral meteor
#

it doesn't need to be complicated it just needs to show off the usefulness of self,disp and stdout

wanton tundra
#

im be honest i never heard of disp till now

floral meteor
#
disp("Hello World!")
#

comes from matlab

#

self is a self reference which is probably js or c++

#

and stdout <= s is made to look sort of like shell. I could add a __lt__ attribute to make it open a filename and print its contents

wanton tundra
#

speaking of c++

floral meteor
#

but meh

wanton tundra
#

i wonder if you can programn in pointers and stuff into python

floral meteor
#

you probably could

#

!e ```py
class yeet(str):neg=print
s = yeet("Hello World!")
-s

night quarryBOT
#

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

[No output]
floral meteor
#

huh

wanton tundra
#

so that works

floral meteor
#

it prints, but just a newline

wanton tundra
#

does hello world thing just get ignored or is it stored somewhere obscure i wonder

latent obsidian
#

im just going to bless this channel now

cedar herald
#

!e

print(', '.join(map(str, map(lambda x: x / 10, filter(lambda x: x % 10 == 0, range(1, 100))))))
night quarryBOT
#

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

1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0
cedar herald
#

idk, the vanilla version is less readable

tulip crypt
#

This is Perl-worthy

snow beacon
latent obsidian
#

@snow beacon forbiddenfruits

#
from __future__ import annotations

from typing import Callable, TypeVar, List
from collections.abc import Iterable
import builtins

from forbiddenfruit import curse

_T = TypeVar("_T")


def join(self: list, char: str):
    return char.join(map(str, self))


def for_each(self: List[_T], func: Callable[[_T], _T]) -> List[_T]:
    return [func(element) for element in self]


def keep(self: List[_T], func: Callable[[_T], bool]) -> List[_T]:
    return [element for element in self if func(element)]


def remove(self: List[_T], func: Callable[[_T], bool]) -> List[_T]:
    return [element for element in self if not func(element)]


def of_type(self: List[_T], required_type: type) -> List[_T]:
    return [element for element in self if isinstance(element, required_type)]


to_add = {
    "join": join,
    "for_each": for_each,
    "keep": keep,
    "remove": remove,
    "of_type": of_type
}

for typ in [list, range]:
    for k, v in to_add.items():
        curse(typ, k, v)
snow beacon
#

Cool, thanks. By the way: .join(", ") is the exact reverse order of the regular Python version. Maybe join_with would be a clearer name to show it's different.

latent obsidian
#

i mean my join is a list method >.>

snow beacon
#

Even so.

latent obsidian
#

hmm mayhaps

#

i wanna make something similar to reduce (or LINQ's .Aggregate) too

toxic jewel
#

how does that work wtf

viscid nymph
#

__le__

astral rover
#

it creates a new class using type with an le dunder

toxic jewel
#

where does the <= come from

viscid nymph
#

what

#

le

toxic jewel
#

ohhhhhhhhhh

viscid nymph
#

makes it support <=

toxic jewel
#

crazy

lone scarab
#

!e

class Bruh:
    def __init__(self):
        self.self = self

    def p():
        print(self.self)

b = Bruh()
night quarryBOT
#

@lone scarab :warning: Your eval job has completed with return code 0.

[No output]
twilit grotto
#

bruh

lone scarab
#

!e

class Bruh:
    def __init__(self, arg1):
        self.self = self
        self.arg1 = arg1

    def p():
        print(self.self)

b = Bruh("hello world")
night quarryBOT
#

@lone scarab :warning: Your eval job has completed with return code 0.

[No output]
twilit grotto
#

bruh

lone scarab
#

oh shit i forgot self

#

!e

class Bruh:
    def __init__(self, arg1):
        self.self = self
        self.arg1 = arg1

    def p(self):
        print(self.self)

b = Bruh("hello world")
night quarryBOT
#

@lone scarab :warning: Your eval job has completed with return code 0.

[No output]
lone scarab
#

!e

class Bruh:
    def __init__(self, arg1):
        self.self = self
        self.arg1 = arg1

    def p(self):
        print(self.self.self.self.self.self.self.self.self.self.self.self.self.self.self.arg1)

b = Bruh("Hello, world!")
b.p()
night quarryBOT
#

@lone scarab :white_check_mark: Your eval job has completed with return code 0.

Hello, world!
lone scarab
#

bruh python

cloud fossil
#

self is self and so is self therefore self is also self? makes self

lone scarab
#

๐Ÿค”

viscid nymph
#

!e

class E:__eq__=lambda*a:'h';__ne__=lambda*a:'e';__lt__=lambda*a:'l';__gt__=lambda*a:'l';__le__=lambda*a:'o';__ge__=lambda*a:' ';__pos__=lambda*a:'w';__neg__=lambda*a:'o';__add__=lambda*a:'r';__sub__=lambda*a:'l';__mul__=lambda*a:'d';__div__=lambda*a:'!'
__import__('sys').__stdout__.write(''.join((((e:=E())==e),e!=e,e<e,e>e,e<=e,e>=e,+e,-e,e+e,e-e,e*e)))  
night quarryBOT
#

@viscid nymph :white_check_mark: Your eval job has completed with return code 0.

hello world
cloud fossil
#

Has someone tried to make brainf*ck's Hello World program in Python here yet?

viscid nymph
#

!e

__import__('sys').__stdout__.write(''.join(((e:=(type('E', (), dict(__eq__=lambda*a:'h',__ne__=lambda*a:'e',__lt__=lambda*a:'l',__gt__=lambda*a:'l',__le__=lambda*a:'o',__ge__=lambda*a:' ',__pos__=lambda*a:'w',__neg__=lambda*a:'o',__add__=lambda*a:'r',__sub__=lambda*a:'l',__mul__=lambda*a:'d')))())==e,e!=e,e<e,e>e,e<=e,e>=e,+e,-e,e+e,e-e,e*e)))
night quarryBOT
#

@viscid nymph :white_check_mark: Your eval job has completed with return code 0.

hello world
viscid nymph
#

I should use underscores

#

!e

__import__('sys').__stdout__.write(''.join(((_:=(type('__', (), dict(__eq__=lambda*a:'h',__ne__=lambda*a:'e',__lt__=lambda*a:'l',__gt__=lambda*a:'l',__le__=lambda*a:'o',__ge__=lambda*a:' ',__pos__=lambda*a:'w',__neg__=lambda*a:'o',__add__=lambda*a:'r',__sub__=lambda*a:'l',__mul__=lambda*a:'d')))())==_,_!=_,_<_,_>_,_<=_,_>=_,+_,-_,_+_,_-_,_*_)))
night quarryBOT
#

@viscid nymph :white_check_mark: Your eval job has completed with return code 0.

hello world
floral meteor
#

!e ```py
stdout=type("=",(),dict(le=lambda s,o:import('sys').stdout.write(o)))()

stdout <= ''.join(((:=(type('__', (), dict(eq=lambdaa:'H',ne=lambdaa:'e',lt=lambdaa:'l',gt=lambdaa:'!',le=lambdaa:'o',ge=lambdaa:' ',pos=lambdaa:'W',neg=lambdaa:'o',add=lambdaa:'r',sub=lambdaa:'l',mul=lambda*a:'d')))())==,!=,<,<,<=,>=,+,-,+,-,*,>))

night quarryBOT
#

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

Hello World!
frozen holly
#

Couldn't you use << instead of <=

steep mural
#

Why should they have?

floral meteor
#

!e ```py
4 << 5

night quarryBOT
#

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

[No output]
floral meteor
#

left bit shift

#

!e ```py
int.lshift

night quarryBOT
#

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

[No output]
floral meteor
#

ur genius

sturdy rune
#

!eval

night quarryBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

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

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

sturdy rune
#

!e print("Hello world!")

frozen holly
sturdy rune
#

!e import os os.system("dir")

night quarryBOT
#

@sturdy rune :warning: Your eval job has completed with return code 0.

[No output]
sudden willow
#

python bot is pretty secure

#

you can't really get anything

#

!e __import__("os").system("cd /etc/ && ls")

night quarryBOT
#

@sudden willow :warning: Your eval job has completed with return code 0.

[No output]
floral meteor
#
File = ....__class__.__class__("StdoutPipe",(),dict(__init__=lambda s,f:s.__setattr__('f',f),
  __le__=lambda s,o:[(f:=open(s.f,'w')).write(o),f.close()]and o,__lshift__=lambda s,o:[(f:=open(s.f,'a')).write(o),f.close()]and o,
  __ge__=lambda s,o:[(fo:=open(o.f,'w')).write((content:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close(),content][-1],
  __rshift__=lambda s,o:[(fo:=open(o.f,'a')).write((content:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close(),content][-1],
  delete=lambda s:__import__('os').remove(s.f)
))
File("test.txt") <= "Hello "
File("test.txt") << "World!"
File("test.txt") >= File("hello.txt")
File("newline.txt") <= '\n'
File("newline.txt") >> File("hello.txt")
File("newline.txt").delete();File("test.txt").delete()
if __debug__:
  with open("hello.txt",'r') as file:assert file.read()=="Hello World!\n"
#

can't run this with bot because file system

sudden willow
#

dang

floral meteor
#

at this point it looks like a whole different language to python

#

does it work?

sudden willow
#

idk im on my phone in the car

floral meteor
#

it does

#
#filesystem.py
File = ....__class__.__class__("StdoutPipe",(),dict(__init__=lambda s,f:s.__setattr__('f',f),
  __le__=lambda s,o:[(f:=open(s.f,'w')).write(o),f.close()]and o,__lshift__=lambda s,o:[(f:=open(s.f,'a')).write(o),f.close()]and o,
  __ge__=lambda s,o:[(fo:=open(o.f,'w')).write((content:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close()]and content,
  __lt__=lambda s,t:[(before:=(f:=open(s.f,'r+')).read(t[0])+t[1]),(after:=f.read()),f.seek(0),f.write(before+after),f.close()]and t[1],
  __gt__=lambda s,t:[(content:=(f:=open(s.f,'r')).read()),f.close()]and t[1] < (t[0],content),
  __rshift__=lambda s,o:[(fo:=open(o.f,'a')).write((content:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close(),content][-1],
  _delete=lambda s:__import__('os').remove(s.f)
)); stdout = ....__class__.__class__("Stdout",(),dict(__init__=lambda s,f=__import__('sys').__stdout__:s.__setattr_('f',f),
  __le__=__lshift__=lambda s,o:[s.f.write(o),o][1],__ge__=lambda*a:NotImplemented,__gt__=lambda*a:NotImplemented,
  __lt__=lambda s,o:[s.f.write((c:=(f:=open(o.f,'r')).read())),f.close()]and c,_delete=lambda*a:NotImplemented)
delete=....__class__.__class__("Deleter",(),dict(__le__=__lt__=__gt__=__ge__=lambda s,o:o._delete()))()
``````py
#main.py
from filesystem import *
test = File("test.txt")
test <= "Hello"
test << "World!"
test >= File("hello.txt")
File("hello.txt") < (5," ") # insertion make life so much easier
File("newline.txt") <= '\n'
File("newline.txt") >> File("hello.txt")
delete <= File("newline.txt")
delete >= test
stdout << (stdout < File("hello.txt") == "Hello World!\n" and "Exit Code 0" or "Exit Code 1")
delete > File(__file__) # self deleting ahahahaaha
#

So the first half is esoteric python to abstract away the details for the intuitively non-python syntax in the second half

snow beacon
#

That's the gist of it, yes. There's a lot more like it in various parts of this channel.

floral meteor
#

I should save that in my cursed module so I don't have to go through

with open("hello.txt",'a') as file1:
  with open("newline.txt",'r') as file2:
    file1.write(file2.read())
#

okay I think I'm done modifying it do you like it?

#

you can chain writing the same string to multiple files too;

from filesystem import *
foo = File("foo.txt")
foo <= "foo"
File("bar.txt") <= "bar" >> foo
foo < (3," ")
delete <= File("bar.txt")
stdout < foo == "foo bar" and stdout << "Exit Code 0" or stdout << "Exit Code 1"
floral meteor
#
class Zero:O=__call__=lambda*a:0;__inverse__=lambda s:s.o();__init__=lambda s,a:s.__setattr__('o':a)
class One(Zero):O=__call__=lambda*a:1
zero,one=Zero(One),One(Zero)
class Neuron:
  def __init__(s,data=None):s.data=data;s.In=[zero,zero,zero];s.N=zero;s.X=zero;s.f=[]
  def __add__(s,f):s.f+=[f]if hasattr(f,'__call__')else[lambda _:print(f)]
  def __sub__(s,f):f in s.f and s.f.pop(s.f.index(f)) or s.f.pop()
  def O(s):
    result = (all([n()for n in s.In])and not s.N())^s.X()
    if result:[f(s.data)for f in s.f]
    return result
  def __ne__(s,o):s.N=o.O
  def __le__(s,o):s.In[0]=o.O
  def __eq__(s,o):s.In[1]=o.O
  def __ge__(s,o):s.In[2]=o.O
  def __lt__(s,o):s.In=[o.O]*3
  def __gt__(s,o):o.In=[s.O]*3
  def __xor__(s,o):s.X=o.O
class Brain:
  def __init__(self,size):
    """creates a 3D matrix of neurons with size :param:size"""
    self.matrix=[[[Neuron(0)for k in range(size)]for j in range(size)]for i in range(size)]
  __call__=lambda self,x,y=0,z=0:self.matrix[x][y][z]
  __getitem__=lambda self,i:self.matrix[i]
thonk=lambda B:B(0).O()
#

The question is: is that Turing Complete?
EDIT: I made < and > shortcuts for chaining

next flame
#

@floral meteor hm whats the difference between < <= and << in your lib

floral meteor
#

which one?

next flame
#

the c++ iostreams one

floral meteor
#

< takes a tuple of two arguments and inserts the second argument at the first arguments place in the file
<= overwrites the file with the string
<< appends the string to the file

#

as for stdout it makes no difference as you can't seek, read or wipe stdout

#

so there's only append

#

and delete is just a file modifying function

snow beacon
#

(And <<= is bitshifting assignment.)

floral meteor
#
#filesystem.py
File = ....__class__.__class__("Pipe",(),dict(__init__=lambda s,f:s.__setattr__('f',f),
  __le__=lambda s,o:[(f:=open(s.f,'w')).write(str(o)),f.close()]and o,__lshift__=lambda s,o:[(f:=open(s.f,'a')).write(str(o)),f.close()]and o,
  __ge__=lambda s,o:[(fo:=open(o.f,'w')).write((content:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close()]and content,
  __lt__=lambda s,t:[(before:=(f:=open(s.f,'r+')).read(t[0])+t[1]),(after:=f.read()),f.seek(0),f.write(before+after),f.close()]and t[1],
  __gt__=lambda s,t:[(c:=(f:=open(s.f,'r')).read()),f.close()]and t[1] < (t[0],c),__str__=lambda s:[(c:=(f:=open(s.f,'r')).read()),f.close()]and c,
  __rshift__=lambda s,o:[(fo:=open(o.f,'a')).write((content:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close(),content][-1],
  _d=lambda s:__import__('os').remove(s.f)
)); stdout = ....__class__.__class__("Stdout",(),dict(__init__=lambda s,f=__import__('sys').__stdout__:s.__setattr_('f',f),
  __le__=__lshift__=lambda s,o:[s.f.write(o),o][1],__ge__=lambda*a:NotImplemented,__gt__=lambda*a:NotImplemented,
  __call__=lambda s,f=__import__('sys').__stdout__:[s.__setattr__('f',f)]and s,
  __lt__=lambda s,o:[s.f.write((c:=(f:=open(o.f,'r')).read())),f.close()]and c,_delete=lambda*a:NotImplemented)
delete=....__class__.__class__("del",(),dict(__le__=__lt__=__gt__=__ge__=lambda s,o:o._d()))()
def _input(prompt,file=__import__('sys').__stdin__):
  output=""
  while (s:=file.read(1))!='\n':output+=s
  return output
stdin=....__class__.__class__("Stdin",(),dict(
  __call__=lambda s,f=__import__('sys').__stdin__:[s.__setattr__('f':f)]and s,
  __init__=lambda s,f=__import__('sys').__stdin__:[s.__setattr__('f':f),s.__setattr__('p':"")],
  __rshift__=lambda s,p:[p << _input(s.p),s.__setattr__('p',"")][0],
  __ge__=lambda s,p:[p <= _input(s.p),s.__setattr__('p',"")][0],
  __lshift__=lambda s,p:[p,s.__setattr__('p',s.p+p)][0],
  __le__=lambda s,p:[p,s.__setattr__('p',p)][0], __lt__=lambda s,o:s.__le__(o)
))()
#

don't see a use for bitshifting assignment unless you wanna

>>> (foo:=File("foo.txt")) << "foo"
'foo'
>>> foo <<= "bar"
'bar'
>>> stdout << foo
'foobar'
#

!e ```py
def echo(icannamezthisvariablecheezburger):
@print
@lambda :.doc
class _:doc=f"""{icannamezthisvariablecheezburger}"""
return icannamezthisvariablecheezburger
echo(echo(echo("I can haz cheeseburger")))

night quarryBOT
#

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

001 | I can haz cheeseburger
002 | I can haz cheeseburger
003 | I can haz cheeseburger
floral meteor
#

!e ```py
@(lambda n:lambda f:lambda result:[(result:=f(result))for i in range(n)][-1])(6)
def echo(icannamezthisvariablecheezburger):
@print
@lambda :.doc
class _:doc=f"""{icannamezthisvariablecheezburger}"""
return icannamezthisvariablecheezburger+'!'
echo("I can haz cheeseburger")

night quarryBOT
#

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

001 | I can haz cheeseburger
002 | I can haz cheeseburger!
003 | I can haz cheeseburger!!
004 | I can haz cheeseburger!!!
005 | I can haz cheeseburger!!!!
006 | I can haz cheeseburger!!!!!
forest hornet
#

!e s="""print('s=""'+'"'+s+'"'+'"";eval(s)')""";eval(s)

night quarryBOT
#

@forest hornet :white_check_mark: Your eval job has completed with return code 0.

s="""print('s=""'+'"'+s+'"'+'"";eval(s)')""";eval(s)
forest hornet
#

There's my quine

night quarryBOT
#

@viscid nymph :white_check_mark: Your eval job has completed with return code 0.

lol
viscid nymph
#

Oh

twilit grotto
#

eval is cheating

earnest wing
#

"[insert here] is cheating"

twilit grotto
#

it kinda is though

glacial yacht
#

Hello friends. I am coding python ide with pyqt5. I took care of the coloring part of the codes. but I got stuck in running python. As with my request vs code editor, I want to be able to open a terminal in my application, how can I achieve this? If you have an answer to my question, tag me please.

naive roost
#

maybe you want to ask that in a general help channel

#

though you can always do some kind of subprocess magic, spawning the command to open the terminal you have installed, or emulating one yourself inside you application

runic ruin
#

What's the shortest way to make a program that generates a 8 digit string with random uppercase letters, lowercase letters, and numbers?

#
import random;from string import ascii_letters as A, digits as B;print(*(random.choice(A+B) for x in range(16)),sep='')
```The fact that I made this without help impresses me

Almost everything I code involves me asking for help at one point
drifting grove
#

!e ```py
import random as r,string as s
print(''.join([r.choice(s.ascii_letters+s.digits) for i in range(8)]))

night quarryBOT
#

@drifting grove :white_check_mark: Your eval job has completed with return code 0.

CikHcMhl
next flame
#

@drifting grove you dont need the []

drifting grove
#

really?

#

thanks ๐Ÿ™‚

#

!e ```py
import random as r,string as s
print(''.join(r.choice(s.ascii_letters+s.digits) for i in range(8)))

night quarryBOT
#

@drifting grove :white_check_mark: Your eval job has completed with return code 0.

US3AaI19
next flame
#

gen exprs ๐Ÿ™‚

drifting grove
#

I see

#

!e ```py
import random as r,string as s
for i in range(8):print(r.choice(s.ascii_letters+s.digits),end='')

night quarryBOT
#

@drifting grove :white_check_mark: Your eval job has completed with return code 0.

BCRKE13D
drifting grove
#

4 characters less then my previous one

twilit grotto
#

!d random.choices

night quarryBOT
#
random.choices(population, weights=None, *, cum_weights=None, k=1)```
Return a *k* sized list of elements chosen from the *population* with replacement. If the *population* is empty, raises [`IndexError`](exceptions.html#IndexError "IndexError").

If a *weights* sequence is specified, selections are made according to the relative weights. Alternatively, if a *cum\_weights* sequence is given, the selections are made according to the cumulative weights (perhaps computed using [`itertools.accumulate()`](itertools.html#itertools.accumulate "itertools.accumulate")). For example, the relative weights `[10, 5, 30, 5]` are equivalent to the cumulative weights `[10, 15, 45, 50]`. Internally, the relative weights are converted to cumulative weights before making selections, so supplying the cumulative weights saves work.... [read more](https://docs.python.org/3/library/random.html#random.choices)
twilit grotto
#

!e

import random as r,string as s
print(*r.choices(s.ascii_letters+s.digits,k=8),end="")
night quarryBOT
#

@twilit grotto :white_check_mark: Your eval job has completed with return code 0.

0 s s X W X k c
twilit grotto
#

oh wait, sep

naive roost
#

!e ```py
import random as r,string as s
print(*r.choices(s.ascii_letters+s.digits,k=8),sep="")

night quarryBOT
#

@naive roost :white_check_mark: Your eval job has completed with return code 0.

B3O8hotz
naive roost
#

interesting

drifting grove
#

!e ```py
import random as r,string as s
print(*r.sample(s.printable[:62]*8,8),sep="")

night quarryBOT
#

@drifting grove :white_check_mark: Your eval job has completed with return code 0.

wlINqWRp
viscid nymph
#

!d string.printable

night quarryBOT
#
string.printable```
String of ASCII characters which are considered printable. This is a combination of [`digits`](#string.digits "string.digits"), [`ascii_letters`](#string.ascii_letters "string.ascii_letters"), [`punctuation`](#string.punctuation "string.punctuation"), and [`whitespace`](#string.whitespace "string.whitespace").
viscid nymph
#

!e

import random as r,string as s
print(''.join(r.sample(s.printable[:62]*8,8)))
night quarryBOT
#

@viscid nymph :white_check_mark: Your eval job has completed with return code 0.

RTZaIabI
viscid nymph
#

!e print(import('string').printable)

night quarryBOT
#

@viscid nymph :white_check_mark: Your eval job has completed with return code 0.

001 | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ 	
002 | 
003 | 
rugged sparrow
#

!e print(*filter(str.isalnum,map(chr,range(123))))

night quarryBOT
#

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

0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z
rugged sparrow
#

!e py print(*__import__('random').choices([*filter(str.isalnum,map(chr,range(123)))],k=8),sep="")

night quarryBOT
#

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

QYB2PEOW
drifting grove
#

!e print (str.isalnum)

night quarryBOT
#

@drifting grove :white_check_mark: Your eval job has completed with return code 0.

<method 'isalnum' of 'str' objects>
drifting grove
#

!e print("1a.".isalnum())

night quarryBOT
#

@drifting grove :white_check_mark: Your eval job has completed with return code 0.

False
drifting grove
#

!d str.isalnum

night quarryBOT
#
str.isalnum()```
Return `True` if all characters in the string are alphanumeric and there is at least one character, `False` otherwise. A character `c` is alphanumeric if one of the following returns `True`: `c.isalpha()`, `c.isdecimal()`, `c.isdigit()`, or `c.isnumeric()`.
viscid nymph
#

!d str.isalpha

night quarryBOT
#
str.isalpha()```
Return `True` if all characters in the string are alphabetic and there is at least one character, `False` otherwise. Alphabetic characters are those characters defined in the Unicode character database as โ€œLetterโ€, i.e., those with general category property being one of โ€œLmโ€, โ€œLtโ€, โ€œLuโ€, โ€œLlโ€, or โ€œLoโ€. Note that this is different from the โ€œAlphabeticโ€ property defined in the Unicode Standard.
floral meteor
#

Alright, time to improve my cursed File class

radiant anchor
#
#

Python 3.x through 3.9.1 has a buffer overflow in PyCArg_repr in _ctypes/callproc.c, which may lead to remote code execution in certain Python applications that accept floating-point numbers as untrusted input, as demonstrated by a 1e300 argument to c_double.from_param. This occurs because sprintf is used unsafely.

#

!e

import ctypes
x = ctypes.c_double.from_param(1e300)
print(repr(x))
night quarryBOT
#

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

[No output]
blissful crypt
#

Does @night quarry have every pip package installed lmao

snow beacon
#

It has the standard libraries, which includes ctypes, and a few other ones, like forbiddenfruit and maybe numpy?

tribal moon
#

it also has pandas

snow beacon
#

The common ones, I'd guess.

floral meteor
#

Does it have kivy?

#

!e import kivy

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

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

!e import colorama

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

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

!e import main

night quarryBOT
#

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

[No output]
floral meteor
#

!e ```py
import main
print(dir(main))

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

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

LOOOL

#

oh

#

!e ```py
import main
print(dir(main))

night quarryBOT
#

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

['__annotations__', '__builtins__', '__doc__', '__loader__', '__main__', '__name__', '__package__', '__spec__']
floral meteor
#

!e ```py
import main
for this in dir(main): print(this, getattr(main,this))

night quarryBOT
#

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

001 | __annotations__ {}
002 | __builtins__ <module 'builtins' (built-in)>
003 | __doc__ None
004 | __loader__ <class '_frozen_importlib.BuiltinImporter'>
005 | __main__ <module '__main__' (built-in)>
006 | __name__ __main__
007 | __package__ None
008 | __spec__ None
floral meteor
#

!e ```py
from main import builtins as _
for this in dir(): print(this, getattr(,this))

night quarryBOT
#

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

001 | ArithmeticError <class 'ArithmeticError'>
002 | AssertionError <class 'AssertionError'>
003 | AttributeError <class 'AttributeError'>
004 | BaseException <class 'BaseException'>
005 | BlockingIOError <class 'BlockingIOError'>
006 | BrokenPipeError <class 'BrokenPipeError'>
007 | BufferError <class 'BufferError'>
008 | BytesWarning <class 'BytesWarning'>
009 | ChildProcessError <class 'ChildProcessError'>
010 | ConnectionAbortedError <class 'ConnectionAbortedError'>
011 | ConnectionError <class 'ConnectionError'>
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/nohonidaja.txt

floral meteor
#

!e ```py
from main import builtins as _
{ print(this, getattr(,this))for this in dir() if "Error" not in this and "Warning" not in this and "Exception" not in this}

night quarryBOT
#

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

001 | Ellipsis Ellipsis
002 | False False
003 | GeneratorExit <class 'GeneratorExit'>
004 | KeyboardInterrupt <class 'KeyboardInterrupt'>
005 | None None
006 | NotImplemented NotImplemented
007 | StopAsyncIteration <class 'StopAsyncIteration'>
008 | StopIteration <class 'StopIteration'>
009 | SystemExit <class 'SystemExit'>
010 | True True
011 | __build_class__ <built-in function __build_class__>
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/watijafuqa.txt

floral meteor
#

!e ```py
import main
print(420)
raise main.builtins.SystemExit(69)

next flame
#

@floral meteor please use #bot-commands for testing

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 69.

420
floral meteor
#

k

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

001 | 420Traceback (most recent call last):
002 |   File "<string>", line 31, in <module>
003 |   File "<string>", line 27, in <lambda>
004 | NameError: name 'quit' is not defined
floral meteor
#

tf

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 69.

420
floral meteor
#

ahahahahahahaha I am invincible

#

!e ```py
#filesystem.py
class File:
init =lambda s,f:s.setattr('f',f);invert=lambda s:import('os').remove(s.f)and None
le =lambda s,o:[(f:=open(s.f,'w')).write(str(o)),f.close()]and o
lshift=lambda s,o:[(f:=open(s.f,'a')).write(str(o)),f.close()]and o
ge =lambda s,o:[(fo:=open(o.f,'w')).write((c:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close()]and c
rshift=lambda s,o:[(fo:=open(o.f,'a')).write((c:=(fs:=open(s.f,'r')).read())),fo.close(),fs.close()]and c
lt =lambda s,t:[(b:=(f:=open(s.f,'r+')).read(t[0])+t[1]),(a:=f.read()),f.seek(0),f.write(b+a),f.close()]and t[1]
eq =lambda s,p:[(f:=[open(s.f),open(p.f)]),(c:=f[0].read()==f[1].read()),f[0].close(),f[1].close()]and c
gt =lambda s,t:t[1]<(t[0],str(s));str=lambda s:[(c:=(f:=open(s.f,'r')).read()),f.close()]and c
def bool(s):
try:
with open(s.f,'r')as f:return file.read().bool()
except FileNotFoundError:return False
except PermissionError:return False
else:return True
class Stdout:
init =lambda s,f=import('sys').stdout:s.setattr('f',f)
le=lshift=lambda s,o:[s.f.write(o)]and o
call =lambda s,f=import('sys').stdout:[s.setattr('f',f)]and s
lt =lambda s,o:[s.f.write((c:=(f:=open(o.f,'r')).read())),f.close()]and c
rshift=gt=ge=lambda*a:NotImplemented
bool =lambda s:not s.f.closed()
eq =lambda a,b:a.f==b.f
invert =lambda s:s.f.close()or s.class
class Del:lshift=rshift=le=lt=gt=ge=eq=ne=lambda s,o:~o or s
class Exit:call=invert=lshift=rshift=le=lt=gt=ge=eq=ne=lambda s,o=0:import('_sitebuiltins').Quitter("exit","press the x button")(o)
exit=Exit(); del Exit
stdout=Stdout();close=delete=Del();del Del,Stdout
stdout << "420"
try:~exit
except SystemExit:exit << 69

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 69.

420
floral meteor
supple vortex
#

nice

floral meteor
#

it also returns the value so the stream can be chained

#

!e now unfortunately the bot has a restricted file system...

import _sitebuiltins as _
print(_.__file__.__str__())
night quarryBOT
#

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

/usr/local/lib/python3.9/_sitebuiltins.py
floral meteor
#

or does it?

#

!e ```py
filename="/usr/local/lib/python3.9/_sitebuiltins.py"
with open(filename,'r') as file:
print(file.read())

night quarryBOT
#

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

001 | """
002 | The objects used by the site module to add custom builtins.
003 | """
004 | 
005 | # Those objects are almost immortal and they keep a reference to their module
006 | # globals.  Defining them in the site module would keep too many references
007 | # alive.
008 | # Note this means this module should also avoid keep things alive in its
009 | # globals.
010 | 
011 | import sys
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/ugugukarin.txt

floral meteor
#

005 | # Those objects are almost immortal

#

Note this means this module should also avoid keep things alive

#

what is this, a cult?

#

!e ```py
dir="/snekbox/snekbox"
import os
os.chdir(dir)
print(*os.listdir())
import config

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

001 | config.py __main__.py api nsjail.py __init__.py __pycache__
002 | Traceback (most recent call last):
003 |   File "<string>", line 5, in <module>
004 |   File "/snekbox/snekbox/config.py", line 5, in <module>
005 |     from google.protobuf.internal import enum_type_wrapper
006 | ModuleNotFoundError: No module named 'google'
floral meteor
#

no module named google haha

floral meteor
#

Hello there

snow beacon
#

@floral meteor The way the bot replies is rather verbose, so it keeps the chat cleaner if you don't always get the bot to execute your creations.

ionic summit
#

hi guys, i have a question, my code its this rankk = soup.find('table')
rankList = rankk.find_all('tr')
leaderboard = []
for rank in rankList:
sd = rank.find('span')
print(sd.text)

#

and the error is AttributeError: 'NoneType' object has no attribute 'text'

cedar herald
#

This channel is kinda the opposite of that

ionic summit
#

sry

cedar herald
#

np

sick hound
radiant anchor
#

fr? noice

sick hound
#

yhh

#

heard amazon internal tools was offline the whole night

#

to fix it

#

or smth

sick hound
radiant anchor
#

nope, saw the vuln on HN

sick hound
#

ahh

#

he said ur in an irc

#

where he also hangs sometimes

#

@radiant anchor do u know oblivion then

radiant anchor
#

uhhh I don't think so

#

but I do idle in a lot of IRCs

#

and a lot of discords, heh

sick hound
#

Ahh

#

He said he recognised ur name ๐Ÿ˜‚

#

But isnt sure

radiant anchor
#

heh fair enough, I am in a lot of places

toxic jewel
#

just made this

#
while(True):(pcmd:=lambda cmd:(cmds:={"clear":(lambda o: (o.system("cls") if o.name == "nt" else o.system("clear")))(__import__("os"))}))(input("lol:"))
#

original:

import os
import sys

def parsecommand(cmd):
    commands = {
        "clear": (os.system("cls") if os.name == "nt" else os.system("clear")),
    }
    return commands

print("trollar")

while True:
    inp = input("lol: ")

    try:
        parsecommand(inp)
    except:
        print("Invalid command.")
#

not sure how to one line try/except

proper vault
#

contextlib.ContextDecorator

toxic jewel
#

hm

#

how would i make this break if its an invalid command

#
print("d")
while(True):(pcmd:=lambda cmd:(cmds:={"clear":(lambda o: (o.system("cls") if o.name == "nt" else o.system("clear")))(__import__("os"))},(print("invalid cmd"))if cmd not in cmds else ...))(input("lol:"))
lone gust
#

have you ever heard of pep 8?

terse mortar
lone gust
#

!pep 8

night quarryBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

lone gust
#

!pep8

night quarryBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

You can find the PEP 8 document here.

naive roost
#

Invoking PEP 8 on a 10k characters Hello World program? PEP 8 was not made for that, and it's definitely an oversight from the part of the authors

terse mortar
#

yeah, amaras is right. I did not create this with the intension of following pep8 in mind.

bronze anvil
#

!e

class Zero:O=__call__=lambda*a:0;__inverse__=lambda s:s.o();__init__=lambda s,a:s.__setattr__('o':a)
class One(Zero):O=__call__=lambda*a:1
zero,one=Zero(One),One(Zero)
class Neuron:
  def __init__(s,data=None):s.data=data;s.In=[zero,zero,zero];s.N=zero;s.X=zero;s.f=[]
  def __add__(s,f):s.f+=[f]if hasattr(f,'__call__')else[lambda _:print(f)]
  def __sub__(s,f):f in s.f and s.f.pop(s.f.index(f)) or s.f.pop()
  def O(s):
    result = (all([n()for n in s.In])and not s.N())^s.X()
    if result:[f(s.data)for f in s.f]
    return result
  def __ne__(s,o):s.N=o.O
  def __le__(s,o):s.In[0]=o.O
  def __eq__(s,o):s.In[1]=o.O
  def __ge__(s,o):s.In[2]=o.O
  def __lt__(s,o):s.In=[o.O]*3
  def __gt__(s,o):o.In=[s.O]*3
  def __xor__(s,o):s.X=o.O
class Brain:
  def __init__(self,size):
    """creates a 3D matrix of neurons with size :param:size"""
    self.matrix=[[[Neuron(0)for k in range(size)]for j in range(size)]for i in range(size)]
  __call__=lambda self,x,y=0,z=0:self.matrix[x][y][z]
  __getitem__=lambda self,i:self.matrix[i]
thonk=lambda B:B(0).O()
night quarryBOT
#

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

001 |   File "<string>", line 1
002 |     class Zero:O=__call__=lambda*a:0;__inverse__=lambda s:s.o();__init__=lambda s,a:s.__setattr__('o':a)
003 |                                                                                                      ^
004 | SyntaxError: invalid syntax
bronze anvil
#

a

formal sandal
#

converts a RPN expression into bytecode!

#

there are easier ways, but we don't talk about that

snow beacon
#

Interesting...

twilit grotto
#

!e

ฮป = "lambda"
print(ฮป)
night quarryBOT
#

@twilit grotto :white_check_mark: Your eval job has completed with return code 0.

lambda
twilit grotto
#

oh

sturdy hamlet
#
while True:
  print("I am a masochist.")
```this channel in a nutshell
earnest wing
#

while~0 is cooler

lavish shore
#

I made a smol fizzbuzz but it doesn't have dunders, and one can still make out the constants quite readily

#

!e

(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda h: [lambda: None, lambda: print((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: [[[str(n), "fizz"][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)(3)], "buzz"][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)(5)], "fizzbuzz"][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)(15)])(h + 1)) or g(n)(h + 1)][bool(n - h)]())(100)(0)
night quarryBOT
#

@lavish shore :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 2
003 | fizz
004 | 4
005 | buzz
006 | fizz
007 | 7
008 | 8
009 | fizz
010 | buzz
011 | 11
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/bogulibitu.txt

lavish shore
#

!e

(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda h: [lambda: None, lambda: print((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda s: lambda a: lambda b: [[[n, s[:4]][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)(a)], s[4:]][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)(b)], s[:]][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda a: lambda b: lambda c: [lambda: c, lambda: g(a - 1)(b)(c + b)][a > 0]())(a)(b)(0))])(h + 1)("fizzbuzz")(3)(5)) or g(n)(h + 1)][n - h > 0]())((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda a: lambda b: lambda c: [lambda: c, lambda: g(a - 1)(b)(c + b)][a > 0]())((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(u)(2)(2)(0))((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(u)(5)(5)(0))(0))(0)
night quarryBOT
#

@lavish shore :x: Your eval job has completed with return code 1.

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

!e

(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda h: [lambda: None, lambda: print((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda s: lambda a: lambda b: [[[n, s[:4]][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)(a)], s[4:]][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)(b)], s[:]][(lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda n: lambda r: [lambda: not (n - r), lambda: g(n - r)(r)][n - r > 0]())(n)((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda a: lambda b: lambda c: [lambda: c, lambda: g(a - 1)(b)(c + b)][a > 0]())(a)(b)(0))])(h + 1)("fizzbuzz")(3)(5)) or g(n)(h + 1)][n - h > 0]())((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda a: lambda b: lambda c: [lambda: c, lambda: g(a - 1)(b)(c + b)][a > 0]())((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda a: lambda b: lambda c: [lambda: c, lambda: g(a - 1)(b)(c + b)][a > 0]())(2)(2)(0))((lambda f: (lambda x: f(lambda v: x(x)(v)))(lambda x: f(lambda v: x(x)(v))))(lambda g: lambda a: lambda b: lambda c: [lambda: c, lambda: g(a - 1)(b)(c + b)][a > 0]())(5)(5)(0))(0))(0)
night quarryBOT
#

@lavish shore :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 2
003 | fizz
004 | 4
005 | buzz
006 | fizz
007 | 7
008 | 8
009 | fizz
010 | buzz
011 | 11
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/zahemihenu.txt

snow beacon
#

How about a Hello World where the only thing you can do is call functions, e.g. range(int(), len(str(print())))? Any thoughts?

lavish shore
#

someone on here has written something like that but the whole thing uses dunders __these_things__ I think

#

I can try searching a bit

lavish shore
earnest wing
#

So you can only use builtins? Seems like an interesting challenge, much like "only-attributes-and-methods-of-..."

#

I'm assuming syntactic sugar is out, too

#

So none of that a+1, got to use iterators to do that yourself

#

int, len, list, iter, range, zip and str go a long way for numbers

#

plus you can use dir and vars to access a lot of numbers easily

snow beacon
#

The outer call has to be print, so within that has to be some string. Either str or more probably sum or similar.

#

sum can concatenate lists and strings, if you can construct the right ones.

#

Actually, there's chr, so most characters should be doable if you can get the right numbers. sum with range should make that not too difficult.

#

Then the actual concatenation: sum can't actually concatenate strings, if I recall correctly, but list(some character) should give a singleton list with the right characters.

#

So the missing step is turning a list of characters into a string.

#

Oh, actually, now that I think of it, sum wouldn't be perfect for concatenating lists, because you would need to give it a list of those lists in the first place.

#

You could use zip on singleton lists, then sum that iterable to get a tuple version of that list though.

#

I'm on mobile so it's hard to test all of this.

#

Print can normally concatenate strings for you, if you change its sep, but that wouldn't be allowed here.

#

Maybe mapping a custom type over such a list?

#

Or not even that: if you construct an object whose __add__ returns a string, you can use that to concatenate with sum.

#

You might be able to get "__add__" from a dir somewhere in order to use dict and type...

#

You could have the __add__ function be str. That still requires a way to construct that dict though.

#

(str is just type(str()) so that's easy.)

#

Uhh... The rest is left as an exercise for the reader?

naive roost
#

!e ```py
sum('a', 'b')

night quarryBOT
#

@naive roost :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: sum() can't sum strings [use ''.join(seq) instead]
naive roost
#

You probably can't return a string on __add__, you'd have to do something like next(iter(thing)) for it to even work like you want

snow beacon
#

!e ```python
print(sum(list("hello"), type("",(),{"add":str})()))

night quarryBOT
#

@snow beacon :white_check_mark: Your eval job has completed with return code 0.

hello
snow beacon
#

This is roughly what I mean.

#

There's definitely some gaps in the plan.

#

I'm not sure if the extra call to the type is cheating, but there'd be a way around it, like with map and next.

#

Or more likely, iter itself.

earnest wing
#

we have all these available

['abs', 'all', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'display', 'divmod', 'enumerate', 'eval', 'exec', 'filter', 'float', 'format', 'frozenset', 'get_ipython', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']

ignore the ipython / repl specific ones

#

Of course, we really only need to be able to construct arbitrary strings (see: exec)

#

so a custom type might be it

naive roost
#

those + True, False and Ellipsis, but those ones are not really interesting (as you can get False from bool())

earnest wing
#

I think the challenge allows builtin functions only

#

True is also easy with callable(callable)

naive roost
#

also, technically, __import__ is a builtin function

snow beacon
earnest wing
#

well, but what is a Hello, World! but a specific case of all possible programs?

snow beacon
#

True enough.

earnest wing
#

format might be useful

snow beacon
#

I've got annoyingly close to something.

#

I can make a dict for an object with '__add__':str, by zipping dir(int()) with map(type(type(str())), iter(type(str()), int())), but that also sets __class__ to str.

#

That means sum won't accept it anymore.

#
a = dir(int())
s = map(type(type(str())), iter(type(str()), int()))
d = dict(zip(a, s))
c = type(str(), tuple(), d)
o = next(iter(c, int()))
h = sum(list("hello world"), o)
print(h)
```Using a few illegal operations for now.
#

I need a way of removing __class__ from an iterable.

#

Actually, maybe if I reverse it and call next a lot of times...

stark fable
#

next(iter(dir(list()))) is __add__

#

idk if that helps

snow beacon
#

I really need it to be in an iterable, but I think I've found a way to do that.

proper vault
#

is dict(a=1, b=2) cheating?

snow beacon
#

I was trying to avoid that.

proper vault
#

it does make it pretty easy

snow beacon
#

next(zip(dir(tuple()))) seems to be an iterable containing __add__ but not __class__, so I can zip with that.

#
print(
    sum(
        list("hello world"),
        next(iter(
            type(
                str(),
                tuple(),
                dict(zip(
                    next(zip(dir(tuple()))), 
                    map(type(type(str())), iter(type(str()), int()))
                ))
            ),
            int()
        ))
    )
)
```I've gotten this far, we just need to find out a way of getting the list of characters.
#

Oh, zip.

naive roost
#

there's probably a way of playing with True, False, pow and chr

snow beacon
#

Now I just need to construct 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 and 33.

#
print(
    sum(
        next(zip(
            chr(72),
            chr(101),
            chr(108),
            chr(108),
            chr(111),
            chr(44),
            chr(32),
            chr(119),
            chr(111),
            chr(114),
            chr(108),
            chr(100),
            chr(33)
        )),
        next(iter(
            type(
                str(),
                tuple(),
                dict(zip(
                    next(zip(dir(tuple()))), 
                    map(type(type(str())), iter(type(str()), int()))
                ))
            ),
            int()
        ))
    )
)
stark fable
#

72 is len(sum(zip(chr(int())), tuple(dir(int()))))

#

wait, that's 71

#

nevermind, it's 72

snow beacon
#

These might help.```python
In [7]: len(dir(list()))
Out[7]: 47
In [8]: len(dir(str()))
Out[8]: 80
In [9]: len(dir(int()))
Out[9]: 71
In [12]: len(dir(object()))
Out[12]: 23
In [13]: len(dir(tuple()))
Out[13]: 34
In [14]: len(dir(bytes()))
Out[14]: 75
In [15]: len(dir(bytearray()))
Out[15]: 87

stark fable
#

although it's version dependent

#
>>> len(next(zip(chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()),chr(int()))))
108``` is this cheating? ![beecloseloaf](https://cdn.discordapp.com/emojis/722407581875961856.webp?size=128 "beecloseloaf")
snow beacon
#

No, it's just not so concise.

#

More numbers:```python
In [16]: len(dir(complex()))
Out[16]: 49
In [17]: len(dir(set()))
Out[17]: 56
In [18]: len(dir(frozenset()))
Out[18]: 43
In [20]: len(dir(slice(int())))
Out[20]: 27

stark fable
#

hmm

#

do we have a way to subtract? beethinking

#

since len(dir(tuple())) is 34 and we want 33 and 32

snow beacon
#

Not that I can see.

#
In [21]: len(dir(dict()))
Out[21]: 45
In [22]: len(dir(iter(list())))
Out[22]: 27
In [23]: len(dir(range(int())))
Out[23]: 34
In [24]: len(dir(map(type(int()), list())))
Out[24]: 25
In [25]: len(dir(locals()))
Out[25]: 45
In [26]: len(dir(globals()))
Out[26]: 45
In [27]: len(dir(vars()))
Out[27]: 45
```More numbers.
stark fable
#

locals(), globals() and vars() are all dicts, their dirs aren't going to be different

snow beacon
#

I realised that after I'd bothered typing them all out.

stark fable
snow beacon
#
In [28]: len(dir(type(int())))
Out[28]: 71
In [29]: len(dir(classmethod(type(int()))))
Out[29]: 27
In [30]: len(dir(property(type(int()))))
Out[30]: 33
```This should be most of them.
#

(Note the 33.)

earnest wing
#
In [1]: len(dir(callable))
Out[1]: 29
#

for fn objects

naive roost
#

don't forget ```py

len(dir())
7

snow beacon
#

Those numbers are [7, 23, 25, 27, 33, 34, 43, 45, 47, 49, 56, 71, 75, 80, 87] for a nicer format.

stark fable
#

alright, 33 is len(dir(property(type(int()))))

snow beacon
earnest wing
#

you can get pretty much anything between 1x & 2x using len(repr(builtin))

naive roost
#

interesting. I have: ```py

dir()
['annotations', 'builtins', 'doc', 'loader', 'name', 'package', 'spec']

snow beacon
#
In [1]: len(dir())
Out[1]: 22
earnest wing
#

well, my dir() is constantly updated after each ipython prompt

#

stock repl also to a certain extent

#

ideally you'd use a script

#

but

#

also

#

effort

naive roost
#

yeah, of course, why didn't I think of that

#

!e ```py
print(len(dir()))

night quarryBOT
#

@naive roost :white_check_mark: Your eval job has completed with return code 0.

7
snow beacon
#

Okay, that's reasonably convincing.

earnest wing
#

7 seems to be the default

naive roost
#

so if you work with a base interpreter (which you will do here), you can use 7

snow beacon
#
In [2]: len(ascii(chr(int())))
Out[2]: 6
```Small numbers shouldn't be too hard.
#
In [1]: hash(tuple())
Out[1]: 5740354900026072187
```I doubt this will be much help.
stark fable
#

101 is len(sum(zip(dir(classmethod(type(int()))), dir(int())), tuple(dir(list()))))

naive roost
#

len(str(bool())) is 5, and so on

snow beacon
#

We might be able to use small numbers and pow.

naive roost
snow beacon
#

e.g. 10**2.

stark fable
#

and 2**5

snow beacon
earnest wing
#
In [13]: reprs = [(x, len(repr(eval(x)))) for x in names]

In [14]: reprs.sort(key=lambda x: x[1])

In [15]: reprs
Out[15]: [('int', 13), ('map', 13), ('set', 13), ('str', 13), ('zip', 13), ('bool', 14), ('dict', 14), ('list', 14), ('type', 14), ('bytes', 15), ('float', 15), ('range', 15), ('slice', 15), ('super', 15), ('tuple', 15), ('filter', 16), ('object', 16), ('complex', 17), ('property', 18), ('reversed', 18), ('bytearray', 19), ('enumerate', 19), ('frozenset', 19), ('memoryview', 20), ('classmethod', 21), ('id', 22), ('staticmethod', 22), ('abs', 23), ('all', 23), ('any', 23), ('bin', 23), ('chr', 23), ('dir', 23), ('hex', 23), ('len', 23), ('max', 23), ('min', 23), ('oct', 23), ('ord', 23), ('pow', 23), ('sum', 23), ('eval', 24), ('exec', 24), ('hash', 24), ('iter', 24), ('next', 24), ('open', 24), ('repr', 24), ('vars', 24), ('ascii', 25), ('input', 25), ('print', 25), ('round', 25), ('divmod', 26), ('format', 26), ('locals', 26), ('sorted', 26), ('compile', 27), ('delattr', 27), ('getattr', 27), ('globals', 27), ('hasattr', 27), ('setattr', 27), ('callable', 28), ('breakpoint', 30), ('isinstance', 30), ('issubclass', 30), ('display', 33), ('license', 43), ('help', 72), ('credits', 158), ('copyright', 307)]

Here's all the numbers you get with len(repr(x))

stark fable
#

if we can get 2

earnest wing
#

oh wait some of these aren't fns

stark fable
#

which is quite easy ```py

len(str(len(dir(int()))))
2```

earnest wing
#

like copyright and credits

snow beacon
#

Or len(repr(str())).

stark fable
#

oh, yeah

#

let's use that instead beecloseloaf

#

so pow(len(repr(str())), len(str(bool())))

#

is 32

earnest wing
#

you can get every nonzero power of 2 by chaining repr on a string :>

snow beacon
#

Well that would be a systematic way to get every number.

stark fable
#
>>> pow(len(sum(zip(str(bool())),tuple(str(bool())))),len(repr(str())))
100``` here's 100
snow beacon
#

Zero powers of two aren't too difficult.

#

We need 108, 111, 44, 119, and 114.

earnest wing
#

if only we had a logarithm function builtin

#

could just log(power-of-2, 2)

snow beacon
#

We have divmod, which is something.

snow beacon
earnest wing
#

lame, too

#

but works

#

negative numbers?

#

probably something with pow

#

well, strictly speaking you don't need them

#

since you can just exec-eval

#

BUT

snow beacon
#
In [12]: len(str(hash(tuple())))
Out[12]: 19
earnest wing
#

I believe the hash of singletons is constant

#

So it's safe to use those hashes

snow beacon
#
In [25]: len(dir(Exception()))
Out[25]: 31
earnest wing
#

but you can as easily len(repr(enumerate))

earnest wing
snow beacon
#
In [35]: len(str(type(PendingDeprecationWarning())))
Out[35]: 35
earnest wing
#

I guess it isn't necessary to limit ourselves to lower-case builtins.

#

Though, is it necessary to call everything? Or can we do something like dir(str)?

#

I guess calling is fine considering you can type(str())

snow beacon
#

It doesn't work for print and suchlike, but mostly I think it's a manageable restriction.

#
In [45]: len(str(super(type(PendingDeprecationWarning()))))
Out[45]: 50
#

That adds fifteen to numbers.

earnest wing
#
In [12]: len(repr(super(type(PendingDeprecationWarning()), PendingDeprecationWar
    ...: ning())))
Out[12]: 80
#

don't forget 2-arg super

#
In [13]: f = lambda x: len(str(super(type(x()), x())))
In [14]: f(Exception)
Out[14]: 48
In [15]: f(str)
Out[15]: 36
In [16]: f(list)
Out[16]: 38
In [17]: f(OSError)
Out[17]: 44
In [18]: f(PendingDeprecationWarning)
Out[18]: 80
snow beacon
#

We needed 44, so that's good.

earnest wing
#

Which ones do we have?

#

[72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33]

snow beacon
#
print(
    sum(
        next(zip(
            chr(len(sum(zip(chr(int())), tuple(dir(int()))))),
            chr(len(sum(zip(dir(classmethod(type(int()))), dir(classmethod(type(int())))), tuple(dir(list()))))),
            chr(108),
            chr(108),
            chr(111),
            chr(len(repr(super(type(OSError()), OSError())))),
            chr(pow(len(repr(str())), len(str(bool())))),
            chr(119),
            chr(111),
            chr(114),
            chr(108),
            chr(pow(len(sum(zip(str(bool())),tuple(str(bool())))),len(repr(str())))),
            chr(len(dir(property(type(int())))))
        )),
        next(iter(
            type(
                str(),
                tuple(),
                dict(zip(
                    next(zip(dir(tuple()))), 
                    map(type(type(str())), iter(type(str()), int()))
                ))
            ),
            int()
        ))
    )
)
```Here's what I have.
earnest wing
#

108, 109, 111, 114, 119. Alright.

snow beacon
#

111 is len(repr(frozenset(str(type(PendingDeprecationWarning())))))

snow beacon
#

len(range(pow(len(repr(bytes())), len(repr(str()))), pow(len(repr(str())), len(vars())))) is 119, and I'm logging off.

#

Oh, and I found subtraction.

#

len(range(a, b)).

#

len(sum(map(type(list()),bin(hash(tuple()))), dir(frozenset()))) is 108.

#

And with len(sum(map(type(list()),repr(type(FileNotFoundError()))), dir(bytearray()))) for 114, that's everything.

#

w seems to not be working.

#

!e python print( sum( next(zip( chr(len(sum(zip(chr(int())), tuple(dir(int()))))), chr(len(sum(zip(dir(classmethod(type(int()))), dir(classmethod(type(int())))), tuple(dir(list()))))), chr(len(sum(map(type(list()),bin(hash(tuple()))), dir(frozenset())))), chr(len(sum(map(type(list()),bin(hash(tuple()))), dir(frozenset())))), chr(len(repr(frozenset(str(type(PendingDeprecationWarning())))))), chr(len(repr(super(type(OSError()), OSError())))), chr(pow(len(repr(str())), len(str(bool())))), chr(len(sum(map(type(list()),repr(type(ConnectionRefusedError()))), dir(bytearray())))), chr(len(repr(frozenset(str(type(PendingDeprecationWarning())))))), chr(len(sum(map(type(list()),repr(type(FileNotFoundError()))), dir(bytearray())))), chr(len(sum(map(type(list()),bin(hash(tuple()))), dir(frozenset())))), chr(pow(len(sum(zip(str(bool())),tuple(str(bool())))),len(repr(str())))), chr(len(dir(property(type(int()))))) )), next(iter( type( str(), tuple(), dict(zip( next(zip(dir(tuple()))), map(type(type(str())), iter(type(str()), int())) )) ), int() )) ) )

night quarryBOT
#

@snow beacon :white_check_mark: Your eval job has completed with return code 0.

Hello, world!
snow beacon
#

We did it!

#

Could do with some golfing, of course, but what couldn't?

astral cove
viral rose
#

Crack boost coding abilities

sick hound
#

that really is esoteric

snow beacon
stark fable
#

next challenge: write hello world in 2 characters

snow beacon
#

Amendment: you can do anything if you put your mind to it, unless that thing has to be done in two characters.

stark fable
#

hello world in 3 characters then?

snow beacon
#

Amendment: you can do anything if you put your mind to it, and it wasn't suggested by someone on #esoteric-python.

#

Corollary: that's 'if', not 'iff', so if the suggestion is Hello World with only function calls, you can still do it by putting your mind to it.

lavish shore
#

wow that's cursed

#

cuz if I see chr, then I know what's happening
I don't get the sum and next parts tho, I'm guessing I'd have to look through the iter docs again to get what's going on there

astral rover
#

sum is just concatenating the characters

snow beacon
#

next(zip(...)) makes a tuple of all the characters. The next step would be to sum( ) the tuple, except that Python explicitly disallows putting a string as the second argument to sum, i.e. the 0 value that it starts adding from.

#

Instead of a string as the initial value, we construct and instantiate a type where .__add__(something) is str(something).

#

To do that, we need a dictionary, which needs an iterable in the form [(key, value), ...]. That's just zipping together an iterable of keys with an iterable of values.

#

The value part is easy (though verbose). It's map(type, iter(str, 0)) or iter(lambda: str, 0).

#

That's an iterable that will endlessly repeat str until str == 0.

#

(Never.)

#

Then we just zip that iterator with something that contains "__add__". We get the "__add__" from dir(tuple()), except the dir also contains "__class__", and we can't construct our object with .__class__ = str, because then sum will reject it.

#

Instead, we zip dir(tuple()) (only one iterable) and take the first element using next( ), which will be ("__add__",), because that's the first alphabetically in dir(tuple()).

#

So it makes a type("", (), {"__add__":str}) then calls it using next(iter( )).

#

I learnt a lot about sum when I tried to make a program that multiplies integers (and floats and lists and strings and...) without actually using multiplication, division etc.

#

Or loops.

#

I'm pretty sure I eventually even got it to work on complex numbers.

astral rover
#

Oh I didn't know sum didn't work for characters

high garnet
#

...what.

snow beacon
high garnet
#

I saw something much further above

#

I didn't realise I was in history

lavish shore
#

best way to learn -- I thought sum only summed nums x3

rustic aspen
#

so i know that this channel is basically dedicated to spaghettification but what about using so little characters that it becomes unreadable

snow beacon
#

We do golfing too.

latent obsidian
#

i go into this server

#

to be assaulted with that

lavish shore
#

can someone pin it? I think it's inspirational

terse mortar
#

na

#

there have been much worse hello world programs

lavish shore
#

within the character limit?

terse mortar
lavish shore
#

fair but the ability to demo somethin is a factor imo
like how I can't post my brainfk thing here directly

terse mortar
#

like there was a 10k char one made the other day that could still be made longer

lavish shore
#

hmm if we're going by max length then that's somethin

terse mortar
#

(it was also a oneliner)

lavish shore
#

darn

#

maybe I saw excerpts of it

snow beacon
terse mortar
bronze anvil
#

anyone have any suggestions on how i can make this more esoteric?

bot = commands.Bot(
    command_prefix = fowprefix,
    case_insensitive = True,
    intents = discord.Intents.all(),
    #messages
    #guilds
    #reactions
    #members 
    #presences
    
    status = discord.Status.online,
    #online
    #idle
    #dnd
    #offline?
    
    activity = discord.Activity(
        type = discord.ActivityType.playing, 
        #playing
        #streaming
        #listening
        #watching
        
        name = "with commands"
        )
    )
toxic jewel
#

i would do
(lambda c: ...)(__import__("importlib").importmodule("discord.ext.commands").Bot(config stuff))

terse mortar
round violet
bronze anvil
terse mortar
#

Lol no need to get so pissed off. You made your code actually readable, like that's what pycharm reformat would do. I'll try to find the esoteric bot, but it's not my top priority rn.

bronze anvil
#

the esoteric bot lol

drifting grove
#

!e ```py
[(String:=type('String',(),{'setattr':lambda x,y,z:[(globals().update({y:z}) if not y in globals() else (___ for ___ in()).throw(Exception(f'{y} is already defined'))) if type(z)==str else(a for a in[]).throw(Exception(f'Cannot assign "{type(z).name}" with String keyword'))]})()),(Int:=type('Int',(),{'setattr':lambda x,y,z:[(globals().update({y:z}) if not y in globals() else (___ for ___ in()).throw(Exception(f'{y} is already defined'))) if type(z)==int else(a for a in[]).throw(Exception(f'Cannot assign "{type(z).name}" with Int keyword'))]})()),(Bool:=type('Bool',(),{'setattr':lambda x,y,z:[(globals().update({y:z}) if not y in globals() else (___ for ___ in()).throw(Exception(f'{y} is already defined'))) if type(z)==bool else(a for a in[]).throw(Exception(f'Cannot assign "{type(z).name}" with Bool keyword'))]})()),(Float:=type('Float',(),{'setattr':lambda x,y,z:[(globals().update({y:z}) if not y in globals() else (___ for ___ in()).throw(Exception(f'{y} is already defined'))) if type(z)==float else(a for a in[]).throw(Exception(f'Cannot assign "{type(z).name}" with Float keyword'))]})())]

Int. meaning = 42
String. lie = "cake"
Bool. my_bool = True
Float. pi = 3.14159

night quarryBOT
#

@drifting grove :warning: Your eval job has completed with return code 0.

[No output]
drifting grove
#

Probably not the best version of this possible but I don't feel like making it better right now

frozen holly
#

hello world except no functions or methods can have any arguments

proper vault
#

!e

import __hello__
night quarryBOT
#

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

Hello world!
frozen holly
#

urgh i forgot about that

#

ok excluding that module

snow beacon
#

There's a version without brackets or imports.

frozen holly
#

does it use python 2?

snow beacon
#

No, it goes something like```python
hello = lambda _: "Hello, world!"
@print
@hello
class _:0

rugged sparrow
#

!e ```python
@print
@lambda _:"Hello World"
class _:0

night quarryBOT
#

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

Hello World
floral meteor
#

!e ```py
import idlelib
print(idlelib.tree.BUTT)

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | AttributeError: module 'idlelib' has no attribute 'tree'
floral meteor
#

what a load of garbage

rugged sparrow
#

!e py from idlelib import tree print(tree.BUTT)

night quarryBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 |   File "/usr/local/lib/python3.9/idlelib/tree.py", line 19, in <module>
004 |     from tkinter import *
005 |   File "/usr/local/lib/python3.9/tkinter/__init__.py", line 37, in <module>
006 |     import _tkinter # If this fails your Python may not be configured for Tk
007 | ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
rugged sparrow
#

@floral meteor thats prob why it fails

floral meteor
#

lol

molten sky
#

!e

print(['fizzbuzz' if x % 3 == 0 and x % 5 == 0 else 'fizz' if x % 3 == 0 else 'buzz' if x % 5 == 0 else x for x in range(1, 101)])
night quarryBOT
#

@molten sky :white_check_mark: Your eval job has completed with return code 0.

[1, 2, 'fizz', 4, 'buzz', 'fizz', 7, 8, 'fizz', 'buzz', 11, 'fizz', 13, 14, 'fizzbuzz', 16, 17, 'fizz', 19, 'buzz', 'fizz', 22, 23, 'fizz', 'buzz', 26, 'fizz', 28, 29, 'fizzbuzz', 31, 32, 'fizz', 34, 'buzz', 'fizz', 37, 38, 'fizz', 'buzz', 41, 'fizz', 43, 44, 'fizzbuzz', 46, 47, 'fizz', 49, 'buzz', 'fizz', 52, 53, 'fizz', 'buzz', 56, 'fizz', 58, 59, 'fizzbuzz', 61, 62, 'fizz', 64, 'buzz', 'fizz', 67, 68, 'fizz', 'buzz', 71, 'fizz', 73, 74, 'fizzbuzz', 76, 77, 'fizz', 79, 'buzz', 'fizz', 82, 83, 'fizz', 'buzz', 86, 'fizz', 88, 89, 'fizzbuzz', 91, 92, 'fizz', 94, 'buzz', 'fizz', 97, 98, 'fizz', 'buzz']
molten sky
#

i finally did it

floral meteor
#

The first thing i made in python was similar to that, but it also multiplied the word by its index

#

so

1 
2 2
fluffy fluffy fluffy
yeet yeet yeet yeet
5 5 5 5 5
fluffy fluffy fluffy fluffy fluffy fluffy
7 7 7 7 7 7 7
yeet yeet yeet yeet yeet yeet yeet yeet

and so on

molten sky
#

oh god lol

floral meteor
#

and it was extremely inefficient

#

as i had no prior interaction with python, and couldn't be bothered looking it up

#

so i just vomited codey sounding stuff into it until something worked

molten sky
#

code gambling

#

(as i like to call it)

floral meteor
#

which is how I've eventually gotten to stuff like this:

molten sky
floral meteor
#

!e ```py
import sys as sus
sus.stderr.close()
sus.stdin.close()
sus.stdout.close()
p=print
p('p')

night quarryBOT
#

@floral meteor :warning: Your eval job has completed with return code 1.

[No output]
floral meteor
#

ha return code 1 but no error message AHAHAHAAHAHAAHAAHAHAHAAHJUA

#

I BORKE PYTHON

twilit grotto
#

i mean, how is it gonna tell you what the error is, you closed the stream

floral meteor
#

It even denotes one line of input with

std > File("input.txt")

or

>>> prompt="> "
>>> std <= prompt and _input = std >> std
> fluffy
fluffyTrue
>>> std << _input
fluffy'fluffy'
>>> exit << 0
#

that returns the value, hence might be chaotic if you're in a console and the evaluated output gets echoed as well as the standard output write

#

but in a script....

foggy night
#

Holy hell

#

I have never seen code written like that

tidal canyon
#

i absolutely hate and love that this was the first thing i see when i open this channel

floral meteor
#
# __input.py
from cursedfiles import *
prompt = "> "
std <= prompt and _input = std >> std
std << _input
exit << 0
E:\\>REM TERMINAL
E:\\>py
``````py
>>> import __input
> fluffy
fluffyfluffy
``````bat
EXIT CODE 0
foggy night
#

So you basically just scripted your own terminal commands @floral meteor?

#

So esoteric is just writing the shortest code possible ain't it?

floral meteor
foggy night
floral meteor
foggy night
#

Oh

#

God, I never want to do golfing

#

My head hurts reading that script lol

#

But I must say, well done... Even though I could barely make out anything happening lol

floral meteor
#

alright y'all...

#

a challenge for ya

#
dict(__call__="object()",__neg__="-object",__pos__="+object",__invert__="~object",__eq__="a == b",__lt__="a < b",__le__="a <= b",...)

What's an esoteric way to generate a dictionary similar to the above, uses less characters than outright typing up all syntax descriptions, etc...

earnest wing
#

Not much, since there isn't really a collection of all the syntactic sugar and the dunders associated with them

#

It's also a mixture of prefix, postfix, infix

floral meteor
#

so something like the above would have to be manually generated?

earnest wing
#

Well you could generalize it somewhat

#

e.g. all binops

#

There might also be helpful enums in the ast module, not sure

floral meteor
#

what if I was willing to input to a function a list of dunders that i want in the dictionary output?

#

in that case, what would be the most... unholy way of retreiving the syntax shortcuts for the dunders?

#

or the other way around

#

i.e. something like

_input = "<"
try:eval(f"_input {_input} b")
except ValueError as e:get_dunder_name(e)

maybe?

#

it's a challenge, hence it's gonna be challenging :P

#

!e ```py
try:str() + ...
except TypeError as e:print(e.traceback.tb_frame.f_code.co_name)

night quarryBOT
#

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

<module>
floral meteor
#

awww

earnest wing
#

Well, if you compile "a binop b" you can probably retrieve the dunder

#

From the code object

floral meteor
#

!e ```py
try:str() + ...
except TypeError as e:print(e.traceback.tb_frame.f_back.f_code.co_name)

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: can only concatenate str (not "ellipsis") to str
004 | 
005 | During handling of the above exception, another exception occurred:
006 | 
007 | Traceback (most recent call last):
008 |   File "<string>", line 2, in <module>
009 | AttributeError: 'NoneType' object has no attribute 'f_code'
earnest wing
#

!eval ```py
def foo(a,b):
return a ** b
import dis
dis.show_code(foo)

night quarryBOT
#

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

001 | Name:              foo
002 | Filename:          <string>
003 | Argument count:    2
004 | Positional-only arguments: 0
005 | Kw-only arguments: 0
006 | Number of locals:  2
007 | Stack size:        2
008 | Flags:             OPTIMIZED, NEWLOCALS, NOFREE
009 | Constants:
010 |    0: None
011 | Variable names:
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/copukefoyi.txt

earnest wing
#

Maybe not

floral meteor
#

!e ```py
print(dir((lambda a,b:a+b).code))

night quarryBOT
#

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

['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars', 'co_kwonlyargcount', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_posonlyargcount', 'co_stacksize', 'co_varnames', 'replace']
floral meteor
#

!e print((lambda a,b:a+b).__code__.co_code)

night quarryBOT
#

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

b'|\x00|\x01\x17\x00S\x00'
floral meteor
#

!e ```py
print([this.code.co_code for this in [
lambda a,b:a+b,lambda a,b:a-b,
lambda a,b:a
b,lambda a,b:a**b,
lambda a,b:a/b,lambda a,b:a//b,
lambda a,b:a<b,lambda a,b:a>b,
lambda a,b:a<=b,lambda a,b:a>=b,
lambda a,b:a==b,lambda a,b:a!=b
]])

night quarryBOT
#

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

b'|\x00|\x01\x17\x00S\x00' b'|\x00|\x01\x18\x00S\x00' b'|\x00|\x01\x14\x00S\x00' b'|\x00|\x01\x13\x00S\x00' b'|\x00|\x01\x1b\x00S\x00' b'|\x00|\x01\x1a\x00S\x00' b'|\x00|\x01k\x00S\x00' b'|\x00|\x01k\x04S\x00' b'|\x00|\x01k\x01S\x00' b'|\x00|\x01k\x05S\x00' b'|\x00|\x01k\x02S\x00' b'|\x00|\x01k\x03S\x00'
floral meteor
#

so, stripping the common characters, k means it returns a boolean and the character after that is the id of the comparison binop
just a singular character is the id of the operation binop.

#

| 0x01 must mean begin operator sequence, | 0x00 must mean first input, S 0x00 must mean second input, I'd hate to see a third, k is comparison operator, the following is an id 0x00-0x1f possibly, und 0x00-0x1f is just normal binops, possibly inclusive of bitwise.

#

!e ```py
print([this.code.co_code for this in [
lambda a,b:a+b,lambda a,b:a-b,
lambda a,b:a
b,lambda a,b:a**b,
lambda a,b:a/b,lambda a,b:a//b,
lambda a,b:a^b,lambda a,b:a%b,
lambda a,b:a<b,lambda a,b:a>b,
lambda a,b:a<=b,lambda a,b:a>=b,
lambda a,b:a==b,lambda a,b:a!=b,
lambda a,b:a|b, lambda a,b:a&b
]])

night quarryBOT
#

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

b'|\x00|\x01\x17\x00S\x00' b'|\x00|\x01\x18\x00S\x00' b'|\x00|\x01\x14\x00S\x00' b'|\x00|\x01\x13\x00S\x00' b'|\x00|\x01\x1b\x00S\x00' b'|\x00|\x01\x1a\x00S\x00' b'|\x00|\x01A\x00S\x00' b'|\x00|\x01\x16\x00S\x00' b'|\x00|\x01k\x00S\x00' b'|\x00|\x01k\x04S\x00' b'|\x00|\x01k\x01S\x00' b'|\x00|\x01k\x05S\x00' b'|\x00|\x01k\x02S\x00' b'|\x00|\x01k\x03S\x00' b'|\x00|\x01B\x00S\x00' b'|\x00|\x01@\x00S\x00'
floral meteor
#

okay it looks like b and @ have their own sequence initial letter, then the sequence is terminated by a 0x00 as well as A and 6

#

!e ```py
print(*[this.code.co_code for this in [
lambda a:-a,lambda a:+a,lambda a:~a,lambda a:a(),lambda a:a(a)
]])

night quarryBOT
#

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

b'|\x00\x0b\x00S\x00' b'|\x00\n\x00S\x00' b'|\x00\x0f\x00S\x00' b'|\x00\x83\x00S\x00' b'|\x00|\x00\x83\x01S\x00'
floral meteor
#

okay that's a little confusinger but I think i got it

#

it loads the input first, | means LOAD 0x00 is a value given to it, 0x0b and 0x0a and + and -, 0x0f is ~, 0x83 0x00 is call and pull 0 args; | 0x00 0x83 0x01 means load an input onto stack, then pass the top of the stack to call of next value in the stack

#

so i had S 0x00 wrong before, I think that's EOF

floral meteor
#

I made a help command for my cursed iostreams

#

getattr returns the value, setattr pipes the value to the other end of the equals sign

rugged sparrow
#

@floral meteor k is the COMPARE_OP opcode, its arg designates the comparison. the comparison is done on the top 2 items on the stack, and the result (True vs False) is put on top of the stack.

floral meteor
#

Ah, so the S 0xxx means return stack value?

rugged sparrow
#

ie stack before COMPARE_OP(==): [1, 2], stack after [False]

#

S is the RETURN_VALUE opcode

#

it returns the top of the stack

#

(ending the function)

#

basically (as of python3) all opcodes take a single 0-255 arg

#

not all opcodes use that arg tho (afaik RETURN_VALUE does not)

floral meteor
#

mmmmmm
how do I make a thingy such that when I supply bytecode and some inputs it returns the stuffs?

rugged sparrow
#

youre gonna need to be more specific than that

floral meteor
#

cos then i could use a dictionary like

{"2":{"+":[17],"-":[18],"*":[14],"**":[13],"<":["k",0]},"1":{"-":[0x0b],"+":[0x0a]}}

and feed the my_symbol keyed value of that and a number of inputs to a function that then spits out... a function

#

or a dunder

rugged sparrow
#

i still dont understand what your goal is

floral meteor
#

either a syntax to dunder translator or back

rugged sparrow
#

so like + to __add__?

floral meteor
#

yeah

#

more like a + b to __add__ and + a to __pos__

rugged sparrow
#

so mapping bytecode to the dunders it will call?

#

that is tricky

floral meteor
#

!e ```py
a = lambda b,c:b+c
d = lambda b,c:b.add(c)
print(a.code.co_code,d.code.co_code)
print(a.code==d.code)

night quarryBOT
#

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

001 | b'|\x00|\x01\x17\x00S\x00' b'|\x00\xa0\x00|\x01\xa1\x01S\x00'
002 | False
earnest wing
#

Systematically scrape the Data Model page :>

rugged sparrow
#

parsing Bytecode -> Dunders is easy

#

Bytecode that calls Dunders -> Bytecode that does it directly is hard as hell

floral meteor
#

0xa0 0x00 means load __add__ attribute of top of stack?

rugged sparrow
#

run dis.dis on your functions

#

!e py import dis dis.dis(lambda b,c: b+c)

night quarryBOT
#

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

001 |   2           0 LOAD_FAST                0 (b)
002 |               2 LOAD_FAST                1 (c)
003 |               4 BINARY_ADD
004 |               6 RETURN_VALUE
floral meteor
#

!e ```py
a = lambda b,c:b+c
d = lambda b,c:b.add(c)
print(a.code.co_code,d.code.co_code)
print(a.code==d.code)
import dis
print(dis.dis(a),dis.dis(d))

night quarryBOT
#

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

001 | b'|\x00|\x01\x17\x00S\x00' b'|\x00\xa0\x00|\x01\xa1\x01S\x00'
002 | False
003 |   1           0 LOAD_FAST                0 (b)
004 |               2 LOAD_FAST                1 (c)
005 |               4 BINARY_ADD
006 |               6 RETURN_VALUE
007 |   2           0 LOAD_FAST                0 (b)
008 |               2 LOAD_METHOD              0 (__add__)
009 |               4 LOAD_FAST                1 (c)
010 |               6 CALL_METHOD              1
011 |               8 RETURN_VALUE
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/hivumakeza.txt

rugged sparrow
#

!e py import dis dis.dis(lambda b,c:b.__add__(c))

night quarryBOT
#

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

001 |   2           0 LOAD_FAST                0 (b)
002 |               2 LOAD_METHOD              0 (__add__)
003 |               4 LOAD_FAST                1 (c)
004 |               6 CALL_METHOD              1
005 |               8 RETURN_VALUE
rugged sparrow
#

LOAD_* (other then LOAD_CONST) use co_names to get the name of a variable/attribute/method and then get the value for that name

#

LOAD_CONST indexs the co_consts array directly

floral meteor
#

and LOAD_FAST gets the input?

rugged sparrow
#

LOAD_FAST gets the value in the fastlocals array at the index of its argument

#

the name of the variable that it is getting the value of is code_obj.co_varnames[arg]

signal sonnet
#

I understand

rugged sparrow
#

as a rule, LOAD_* pushes a value onto the stack

floral meteor
#

ah, so that would include the locals &/| globals at the time of defining the lambda?

rugged sparrow
#

there is a description of what each opcode does

floral meteor
#

noice

floral meteor
#

@toxic jewel speaking of minecraft command blocks I made an actual fork bomb

#

and successfully fork bombed my pc

toxic jewel
#

(lambda: "Esoteric Javascript")()

#

whats a fork bomb

#

oh

floral meteor
#

but in minecraft command blocks looks more like...
hang on this is gonna be a big typey-typey

#

oh it's been so long i forgot minecraft commands syntax

#

I'll pseudo code the damn thing

toxic jewel
#

/command <shit here>

floral meteor
#

no shit it's the <shit here> i forgot

toxic jewel
#

i think most of the actual <shit here> is js

floral meteor
#

also in command blocks you don't need the /

earnest wing
#

And this is esoteric python?

floral meteor
#

k i'll write it in python then

floral meteor
#

@toxic jewel

#

how do I flatten this 4-Dimensional monstrosity?
I still count functions as nested.

from data import bombs, w, x, y, z, return_data # replace stuff
numbers = [[[[bombs[_][__][___][____]for _ in range(w)]for __ in range(x)]for ___ in range(y)]for ____ in range(z)]
for I in range(w):
 for J in range(x):
  for K in range(y):
   for L in range(z):
    for i in range(I-1,I+2):
     if 0<=i<w:
      for j in range(J-1,J+2):
       if 0<=j<x
        for k in range(K-1,K+2):
         if 0<=k<y
          for l in range(L-1,L+2):
           if 0<=l<z and bombs[i][j][k][l]:numbers[i][j][k][l]+=1
return_data(numbers)
#

lambdas: depends how you use them

#

ciao

proud wind
#

hi

remote minnow
#

umm, can someone plz explain to me what this channel is for, I read the description too, but I didn't get it. sorry

snow beacon
#

In other channels you might learn 'conventions', 'best practices' and 'readability'. This one avoids all of those things as much as possible. If you don't know how some feature of Python works, chances are it's a central part of some code snippet in this channel.

#

A lot of it is challenges. For instance, can you write a Hello World program that doesn't use strings, loops, imports or anything except function calls? It turns out you can: #esoteric-python message
We also have a variety of weird Fibonacci functions, e.g. #esoteric-python message
And someone managed to make a version of ctypes in Pure Python: #esoteric-python message

boreal slate
snow beacon
#

Assuming no unrecognised letters: sum(map(lambda x:1+('`'<x<'{')+2*('@'<x<'['),my_string))

#

Or, sum(1+('`'<x<'{')+2*('@'<x<'[')for x in my_string) would be shorter.

#

Wait, that doesn't work.

#

sum(1-('`'<x<'{')+('@'<x<'[')for x in my_string) might work?

#

No, that's not it either. sum(3-2*('`'<x<'{')-('@'<x<'[')for x in my_string) This should be right.

earnest wing
#

x < 'c' is a good trick to know

boreal slate
#

oo nice, never thought of this, i have used this before but something things don't pop up in your mind

dire yew
sudden osprey
#
for I in range(w):
 for J in range(x):
  for K in range(y):
   for L in range(z):
     # do something here

could be

for I, J, K, L in itertools.product(w, x, y, z):

But with that many nested loops I think you could do with a larger refactoring

#

well, this is esoteric-python I guess...

toxic jewel
#
while 1:(lambda p: (
  (lambda d: (exec(d.get(p)))if p in d else print("invalid command"))({"clear": "(lambda o: o.system('cls')if o.name == 'nt' else o.system('clear'))(__import__('os'))"})
))(input("root@localhost $ "))
#

just made this

#

have to fit the clear into text because else itll execute on all commands ๐Ÿ˜ฉ

hard spoke
toxic jewel
sudden osprey
toxic jewel
#

oh my god

terse mortar
#
token = "put your token here"

(lambda c, a: [
    f(c, a) for f in [
        
        lambda c, a: [c.__setattr__(k, a.coroutine(v)) for k, v in {
            "on_ready": lambda: print("Ready!"),
        }.items()],

        lambda c, a: [c.command(name = k)(a.coroutine(v)) for k, v in {
                "ping": lambda ctx: c.loop.create_task(ctx.send("Pong!"))
            }.items()],
        
        lambda c, a: c.load_extension("jishaku"),

        lambda c, a: c.run(token)
    ]
])(
    __import__("importlib").import_module("discord.ext.commands").Bot(command_prefix = "lambda: "),
    __import__("asyncio")
)
bronze anvil
terse mortar
#

A discord bot

bronze anvil
#

jishaku

#

whats this

last locust
#

!pypi jishaku

night quarryBOT
#
Author

Devon (Gorialis) R

Requires Python

=3.6.0

Summary

A discord.py extension including useful tools for bot development and debugging.

License

MIT

last locust
#

@bronze anvil ^

#

It's an owner-only eval command basically

bronze anvil
#

oh right

#

ta

toxic jewel
#

trying to figure out how i can not only make this code in a dictionary but condense it to my esoteric needs

while 1:
  d = input(">")

  if "echo" in (d1 := d.split(" ", maxsplit=1)):
    print(d1[1])
formal sandal
terse mortar
toxic jewel
#

:(

#

why does this happen

#

im positive this returns a string

drifting grove
#

it seems to work as expected for me

#

maybe the bug is somewhere else in your code?

toxic jewel
#

thats not the problem

#

the problem is this is my coe

drifting grove
#

oops my bad sorry

toxic jewel
#
while 1:(lambda p: ((lambda d: (exec(d.get(p)))if p in d else (print(f"Command \"{p}\" Not Found.")if p.__len__() != 0 else ...))({"clear": "(lambda o: o.system('cls')if o.name == 'nt' else o.system('clear'))(__import__('os'))","exit": "(print('Terminal Exited Successfully.'),__import__('sys').exit())"})))(input("root@localhost $ "))
#

although maybe i can use walrus as a workaround

#

thats without echo btw

drifting grove
#

I would do something like this (but more esoteric and on one line) that way you don't have to use exec and it makes your code easier to debug (imo)

tidal canyon
#

how often are you using print that you need to alias it?

tardy belfry
#

Heya, what ways are there to find the package name of the running code?

tidal canyon
#

i mean could you not just do:

n = print

?

#

@drifting grove

#

oh wait i think i might be misinterpreting your goals here, sorry.

molten sky
#

is there a tool in python for shortening this boolean expression:

a != b and a != c and a != d \
and b != c and b != d \
and c != d

the more variables I have the worse it gets

tidal canyon
#

are you trying to golf?

molten sky
#

i'm writing a script that generates all possible lottery draws

tidal canyon
#

my first guess is to use the all function somehow.

#

given you are using and

#

so basically are you testing every outcome against every other possible outcome?

molten sky
#

i'm avoiding too much testing

vague hearth
#
>>> from itertools import combinations
>>> all(x != y for x, y in combinations((1, 2, 3, 4), 2))
True
>>> all(x != y for x, y in combinations((1, 2, 3, 3), 2))
False```but probably the wrong channel
tidal canyon
#

hey, itertools.

#

i always wondered if i could get use out of that module.

molten sky
#

thanks i will try that

#

that combinations function may have made my entire script redundant

#

yep it has lemon_xd

#
len([x for x in itertools.combinations(range(59), 6)])
drifting grove
toxic jewel
#

i dont get how you call the lambda

proper vault
#

@molten sky is the goal to see if all variables are distinct?

#

if so len(set(list_of_varialbes)) == len(list_of_variables)

drifting grove
# toxic jewel i dont get how you call the lambda

The lambda object is stored in the dictionary
Almost everything is an object, including functions/lambdas
So it just finds the lambda object in the dictionary and then calls it
You can also do it like this is it makes it clearer:

c = commands[command]
c(args)
sick hound
#

!e py _=((()==())+(()==())) __=(((_<<_)<<_)*_) __import__(('c%'[::(([]!=[])-(()==()))])*((_<<_)+(()==()))%((__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)<<_)+(_<<_))),(__+(((_<<_)<<_)+((_*_)+(()==())))),(__+(((_<<_)<<_)+((_<<_)+(_*_)))),(__+(((_<<_)<<_)+((_<<_)+(_*_)))),(__+(((_<<_)<<_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==()))))))))

night quarryBOT
#

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

Hello world!
sick hound
#

WHAT

#

HOW

molten sky
#

so 1 in 45 mil chance of winning lemon_swag

#

to possibly make it more efficient i could have done a comprehension in a tuple instead of a list

sick hound
#

hi

toxic jewel
#

hello ronbon

twilit grotto
molten sky
cinder grail
# molten sky not something i am familiar with

https://en.wikipedia.org/wiki/Combinatorics

So in this case we want the number of ways to choose 6 balls from 59 balls. There are 59 choices for the 1st ball, 58 for the second ball, 57 for the third, 56 for the 4th, 55 for the 5th, and 54 for the 6th. So, we have 59 * 58 * 57 * 56 * 55 * 54 = 32441381280 different draws, if we care about order. If we don't care about order, we realize that for each 6 balls, there are 6 * 5 * 4 * 3 * 2 * 1 = 720 ways to arrange those balls, so each group of 720 ordered draws in the number 32441381280 is really equivalent to one unordered draw. Thus there are 32441381280 / 720 = 45057474 different possible draws if we don't care about order.

I'm not sure how this helps us figure out what those draws are, however. If you want to know that, I think you need to generate all the combinations.

Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many applications ranging from logic to statistical physics, from evolutionary biology to computer science, etc....

analog rock
#

there are more efficient ways if you only want to know the nth combination, but if you need them all you'd want to generate them all yeah

molten sky
floral meteor
#

what's the windows version?

#

also while you're at it, make it 4-Dimensional ahhahahahhahaha

#

hmm, I feel like something i posted recenttly got deleted

#

_>

rugged sparrow
#

@floral meteor no windows version cause if I remember correctly that minesweeper uses /dev/random to create randomness

#

It also uses terminal control codes that windows ignores

floral meteor
#

how rood

#

:P

#

!e ```py
import itertools
print([[i,j,k,l]for i,j,k,l in itertools.product(range(4),range(4),range(4),range(4))])

night quarryBOT
#

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

[[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 2], [0, 0, 0, 3], [0, 0, 1, 0], [0, 0, 1, 1], [0, 0, 1, 2], [0, 0, 1, 3], [0, 0, 2, 0], [0, 0, 2, 1], [0, 0, 2, 2], [0, 0, 2, 3], [0, 0, 3, 0], [0, 0, 3, 1], [0, 0, 3, 2], [0, 0, 3, 3], [0, 1, 0, 0], [0, 1, 0, 1], [0, 1, 0, 2], [0, 1, 0, 3], [0, 1, 1, 0], [0, 1, 1, 1], [0, 1, 1, 2], [0, 1, 1, 3], [0, 1, 2, 0], [0, 1, 2, 1], [0, 1, 2, 2], [0, 1, 2, 3], [0, 1, 3, 0], [0, 1, 3, 1], [0, 1, 3, 2], [0, 1, 3, 3], [0, 2, 0, 0], [0, 2, 0, 1], [0, 2, 0, 2], [0, 2, 0, 3], [0, 2, 1, 0], [0, 2, 1, 1], [0, 2, 1, 2], [0, 2, 1, 3], [0, 2, 2, 0], [0, 2, 2, 1], [0, 2, 2, 2], [0, 2, 2, 3], [0, 2, 3, 0], [0, 2, 3, 1], [0, 2, 3, 2], [0, 2, 3, 3], [0, 3, 0, 0], [0, 3, 0, 1], [0, 3, 0, 2], [0, 3, 0, 3], [0, 3, 1, 0], [0, 3, 1, 1], [0, 3, 1, 2], [0, 3, 1, 3], [0, 3, 2, 0], [0, 3, 2, 1], [0, 3, 2, 2], [0, 3, 2, 3], [0, 3, 3, 0], [0, 3, 3, 1], [0, 3, 3, 2], [0, 3, 3, 3], [1, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 2], [1, 0, 0, 3], [1, 0, 1, 0], [1, 0, 1, 1], [1, 0, 1, 2], [1, 0
... (truncated - too long)

Full output: https://paste.pythondiscord.com/puhezocaja.txt

floral meteor
#

now that's a nice chunky list

twilit grotto
#

itertools.product(range(4), repeat=4)

#

although, i guess writing it out adds to the effect

floral meteor
#

what if I have four unique objects, as well as 4 range 4s?

#

okay, how do I.... deepen that list?

#

also, can lists be mutated by getitem?

#

!e ```py
a=[0,1]
a[2]=2
print(a)

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | IndexError: list assignment index out of range
floral meteor
#

ouch

#

that and this unstable keyboard connection together makee life suck im just gonna make a listionary object just to get the best of both

twilit grotto
#

well it's not being mutated by getitem, it's using setitem

floral meteor
#

i might've meant setitem...

#

square brackets assignment

#

it mutates dictionaries tho

#

so what if i made a dictionary... with the same indices as a list?

twilit grotto
#

so like, integer keys?

floral meteor
#

aye, so it's just like a list, only squiggly and mutatable

#

i.e. a mutated rip-off of a list

twilit grotto
#

i mean, that's just a worse list

rugged sparrow
#

!e py a=[1,2] a[2:] = 3, print(a)

night quarryBOT
#

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

[1, 2, 3]
floral meteor
#

!e ```py
import itertools
a4d={};a4d[0]=a4d;a4d[0][0][0][0]=0
print(a4d)

night quarryBOT
#

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

{0: 0}
floral meteor
#

๐Ÿค”

#

!e ```py
a=[[[[]]]]
a[0][0][0].append(a)
print(a)
a[0][0][0][0]=0
print(a)
for i,j,k,l in import('itertools').product(range(4),repeat=4):
a[i][j][k][l]+=[0]

night quarryBOT
#

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

001 | [[[[[...]]]]]
002 | [[[[0]]]]
twilit grotto
#

!e
i mean

L = []
L.append(L)
print(L)
night quarryBOT
#

@twilit grotto :white_check_mark: Your eval job has completed with return code 0.

[[...]]
floral meteor
#

!e ```py
a={0:{0:{0:{0:0}}}}
for i,j,k,l in import('itertools').product(range(4),repeat=4):
a[i][j][k].update({l:0})
print(a)

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

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

!e ```py
def self(n=0):
n+=2
f=lambda*a,**k:None
def b(c):
try:raise Exception("\x1b[31mTop level frame, cannot reference.\x1b[0m")
except Exception as e:fr=e.traceback.tb_frame;return[{(fr:=getattr(fr,'f_back'))for _ in range(c)},fr.f_code][1]
f.code=b(n);return f
f = lambda a,b:print(end=str(a)+' ')or self()(b,a+b)
f(0,1)

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

001 | 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 2971215073 4807526976 7778742049 12586269025 20365011074 32951280099 53316291173 86267571272 139583862445 225851433717 365435296162 591286729879 956722026041 1548008755920 2504730781961 4052739537881 6557470319842 10610209857723 17167680177565 27777890035288 44945570212853 72723460248141 117669030460994 190392490709135 308061521170129 498454011879264 806515533049393 1304969544928657 2111485077978050 3416454622906707 5527939700884757 8944394323791464 14472334024676221 23416728348467685 37889062373143906 61305790721611591 99194853094755497 160500643816367088 259695496911122585 420196140727489673 679891637638612258 1100087778366101931 1779979416004714189 2880067194370816120 4660046610375530309 754011380474
... (truncated - too long, too many lines)

Full output: too long to upload

night quarryBOT
#

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

[0,0,0,0,0,1,1,0,0,0,1,0,0.1,0,0.6,0.6,0,0.1,0,0.5,0.5,0.1,0.1,0.1,0.5,0.5,0.5,1,1,0,1,0,1,0,0.8,0.8,0.6,0.1,0,0.1,0.6,0,0,0.6,0.1,0,0.1,0.6,0.1,0.6,1,0.6,0.1,1,0.1,1,0.6,0.6,1,0.1,1,0.1,0.6,1,0.6,0.1,1,0.5,0.5,0.5,1,0.5,0.5,0.5,1,0,0,0.2,0,0.2,0,0.2,0,0,0,0,0.3,0,0.3,0,0.3,0,0,0,0,0.4,0,0.4,0,0.4,0,0,0,0,0.5,0,0.5,0,0.5,0,0,0,0,0.6,0,0.6,0,0.6,0,0,0,0,0.7,0,0.7,0,0.7,0,0,0,0,0.8,0,0.8,0,0.8,0,0,0,0,0.9,0,0.9,0,0.9,0,0,0,0.1,0.1,0.1,0,0.1,0.1,0.1,0,0,0.2,0.2,0.2,0,0.2,0.2,0.2,0,0,0.3,0.3,0.3,0,0.3,0.3,0.3,0,0,0.4,0.4,0.4,0,0.4,0.4,0.4,0,0.4,0.5,0.6,0.5,0.4,0.6,0.6,0.4,0.5,0.4,0.6,0.5,0.5,0.6,0.4,0.6,0.5,0.4,0,0.6,0.6,0.6,0,0.6,0,1,1,0.6,0.7,0,0,0.8,0.7,0.7,0,0.8,0.7,0.6,0,0.6,0.8,0,0,0.9,0.9,0.9,0,0.9,0.9,0.9,0,0.2,0.3,0.4,0.5,0.3,0.2,0.1,0.3,0.2,0.5,0.5,0.5]
floral meteor
#

!e ```py
v = 16
print(tuple([0,0,0,0,0,1,1,0,0,0,1,0,.1,0,.6,.6,0,.1,0,.5,.5,.1,.1,.1,.5,.5,.5,1,1,0,1,0,1,0,.8,.8,.6,.1,0,.1,.6,0,0,.6,.1,0,.1,.6,.1,.6,1,.6,.1,1,.1,1,.6,.6,1,.1,1,.1,.6,1,.6,.1,1,.5,.5,.5,1,.5,.5,.5,1,0,0,.2,0,.2,0,.2,0,0,0,0,.3,0,.3,0,.3,0,0,0,0,.4,0,.4,0,.4,0,0,0,0,.5,0,.5,0,.5,0,0,0,0,.6,0,.6,0,.6,0,0,0,0,.7,0,.7,0,.7,0,0,0,0,.8,0,.8,0,.8,0,0,0,0,.9,0,.9,0,.9,0,0,0,.1,.1,.1,0,.1,.1,.1,0,0,.2,.2,.2,0,.2,.2,.2,0,0,.3,.3,.3,0,.3,.3,.3,0,0,.4,.4,.4,0,.4,.4,.4,0,.4,.5,.6,.5,.4,.6,.6,.4,.5,.4,.6,.5,.5,.6,.4,.6,.5,.4,0,.6,.6,.6,0,.6,0,1,1,.6,.7,0,0,.8,.7,.7,0,.8,.7,.6,0,.6,.8,0,0,.9,.9,.9,0,.9,.9,.9,0,.2,.3,.4,.5,.3,.2,.1,.3,.2,.5,.5,.5][v3//4:v3//4+3]+[1]))

night quarryBOT
#

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

(0.1, 0, 0.6, 1)
floral meteor
#

!e ```py
Sprite=str
@print
@lambda :.doc
class Asteroid(Sprite):
"""Simulate a big'ol asteroid that bounces all over the screen like one
of those 90's DVD screensavers."""

night quarryBOT
#

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

001 | Simulate a big'ol asteroid that bounces all over the screen like one
002 |     of those 90's DVD screensavers.
fossil estuary
#

thats actually cool wtf

#

!e

def Luhn(number):return str(sum([(int(str(int(digit)*2)[0])+int(str(int(digit)*2)[1]) if len(str(int(digit)*2)) == 2 else int(digit)*2) if counter % 2 == 0 else int(digit) for counter,digit in enumerate(str(number))]))[-1] == '0' and len(str(sum([(int(str(int(digit)*2)[0])+int(str(int(digit)*2)[1]) if len(str(int(digit)*2)) == 2 else int(digit)*2) if counter % 2 == 0 else int(digit) for counter,digit in enumerate(str(number))]))) > 1
print(Luhn(15592958922))
#

yes, thats right

night quarryBOT
#

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

False
fossil estuary
#

Most complicated way to see if a number ends in 0

#

and, no u cant do Luhn(0)

floral meteor
#

it's not the most golfed way

#

In this channel, whitespace around operators is considered evil unless used esoterically

#

!e ```py
L=lambda n:str(sum([(int(str(int(d)*2)[0])+int(str(int(d)*2)[1])if len(str(int(d)*2))==2else int(d)*2)if c%2==0 else int(d)for c,d in enumerate(str(n))]))[-1]=='0'and len(str(sum([(int(str(int(d)*2)[0])+int(str(int(d)*2)[1])if len(str(int(d)*2))==2else int(d)*2)if c%2==0else int(d)for c,d in enumerate(str(n))])))>1
print(L(15592958920))

fossil estuary
#

yea

#

well.

#

yeah

night quarryBOT
#

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

True
fossil estuary
#

you found one of the few numbers

floral meteor
#

few?

fossil estuary
#

you can tell what it does

floral meteor
#

you mean one of the 10% of all integers?

fossil estuary
#

its really meant for 16 digit numbers but ya

#

!e

_=()==();__=(_+_)+(_+_);___=((_+_)+(_+_)+(_+_)+(_+_)*(_+_)+(_+_)+(_+_)+(_+_));____="%c"*(_+_+_+_+_)%(((_+_)*((___*__+(__+__))//(_+_))),((_)*((___*__+(__+__)-(_+_+_)))),((_+_)*((___*__+(__+__)+(__))//(_+_))),((_+_)*((___*__+(__+__)+(__))//(_+_))),((_)*((___*__+(__+__)+(__+_+_+_)))))+" "+"%c"*(_+_+_+_+_)%(((_)*((___*__+(__+__)+(__+__+__+_+_+_)))),((_)*((___*__+(__+__)+(__)+(_+_+_)))),((_+_)*((___*__+(__+__)+(__)+(_+_+_)+(_+_+_))//(_+_))),((_+_)*((___*__+(__+__)+(__))//(_+_))),((_+_)*((___*__+(__+__)-(__))//(_+_))));print(____)

night quarryBOT
#

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

HELLO WORLD
fossil estuary
#

one of the projects i made that took a long time

floral meteor
#

ah, yes, PyFuck

fossil estuary
#

i could call it that

floral meteor
#

similar to brainfuck

#

only with underscores

#

instead of registry

fossil estuary
#

time to make it unicode characters :)

#

Did #coding=unicode_escape stop working recently? as i cant get it to work anymore

floral meteor
#

why not make only two variables, __=[];_=__==__?

fossil estuary
#

It worked a few months back. But not anymore

floral meteor
#
# ~-~ coding: utf-8 ~-~

something like that now

fossil estuary
#

i havent even updated python though.

#

but it stopped working..?

floral meteor
#

maybe a module updated while you weren't looking

floral meteor
#

i.e. __[_+_+_] instead of ___

#

that way other than dunders, your locals() or globals() will only consist of _ and __

#

and __ can be indexed, and appended to , rather than having to _______________=________+______<<__*(____+_+_+__)

#

!e print((lambda ab,a,b:ab%a,ab//a%b)(2,4,3))

night quarryBOT
#

@floral meteor :x: Your eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: 'tuple' object is not callable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | NameError: name 'ab' is not defined
floral meteor
#

why that error?

#

!e ```py
thing = lambda ab,a,b:(ab%a,ab//a%b)
print(thing(2,4,3))

night quarryBOT
#

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

(2, 0)
floral meteor
#

did that just do that to me?

#

oh wait

#

x,y

terse mortar
#

Pro tip: you get an error in this channel, you are fucked and can't fix it(most of the time)

floral meteor
#

i can't remember which way around I wanted it

terse mortar
#

Like I had an error in my 10k char hello world onliner and it resulted in me having to restart the full thing bc I couldn't find the error

fossil estuary
#

:(

floral meteor
#

!e ```py
print(7 .divmod(3))

night quarryBOT
#

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

(2, 1)
fluid tree
#

I have a script that makes oneliners

#

10k is waaaaay too much

#

The entire oneliner script, as a oneliner, is only 100k

cloud fossil
rigid yoke
#

hi i have a fairly simple question but i'm not sure how to solve it

#
(lambda x: print(*[i for i in range(1,x+1) if x%i == 0]))(10)
#

how would i change it so that it takes [x for x in range (1,101)]?

naive roost
#

are you sure it's esoteric Python you want, and not asking a general help channel?

cloud fossil
#

my question is why would you need that in your current case

#
(lambda x: print(*list(filter(lambda i: x % i == 0, range(1, 101)))))(10)
#

hey it doesn't even need the list() here

#

cool

naive roost
#

you code is incorrect, technically

cloud fossil
#

wait so you can basically do

(lambda x: print(*[i for i in range(1, 101) if x % i == 0]))(10)
cloud fossil
#

oh i didn't see x+1

#

ye you just change it there no big deal

#

hold on so he wants to check those on all values from 1 through 100?

naive roost
#

the point is taking an iterable as input and spitting out the divisors

cloud fossil
#

kinda curious as to why 101 and x+1 do the same thing here

#

oh ye cuz the number is 10

#

and those are the stuff that 10 can be divided by

naive roost
#

because divisors of x are always less than (or equal to) x

cloud fossil
#

ye ye

#

that's just too many numbers to print for no reason

#

lol

tidal lava
#

hey i tried building a binary tree (and normal trees) yesterday because i needed it for a little project i'm doing to learn stuff, and i'm struggling with finding specific values and their depths.
In particular, since my nodes have just [value, Rchild, Lchild] as attributes, how can i "go up" along the tree if there is no child -> parent relation between nodes (just parent -> child)?

#

i mean, is accessing elements recursively from the root the only option?

naive roost
#

How is it that people ask for help in a channel explicitly designed for esoteric stuff?

#

@ me if you want help from me in that channel, though, maybe I can help

naive roost
#

don't worry about that

rigid yoke
#

i did solve it (albeit badly), here's my code:

naive roost
rigid yoke
#
[(lambda x:print(*[i for i in range(1,x+1) if x%i==0]))(x) for x in range(1,101)]
#

does anyone have any suggestions on how to shorten that further

#

i think it's the shortest i can get it without using some other method

fluid tree
fluid tree
rigid yoke
#

oh wait really?

snow beacon
#

You define a function only to immediately call it.

rigid yoke
rigid yoke
#

how would i cut the lambda out

snow beacon
#

You have something in the form (lambda x: ...)(x) which is equivalent to ....

rigid yoke
#

print(*[i for i in range(1,x+1) if x%i==0]) ?

#

i think i get that but i'm not sure how to put [x for x in range(1,101)] into it

snow beacon
#

Do you know the general form for list comprehensions?

rigid yoke
#

uhhh one sec i borrowed a python book from the library a few weeks ago to learn i think it was in there

#

[<expression> for item in iterable <if optional_condition>]

snow beacon
#

In the old version, what part was the (lambda x:print(*[i for i in range(1,x+1) if x%i==0]))(x)?

fluid tree
#

[print(*[i for i in range(1,x+1) if x%i==0]) for x in range(1,101)]

snow beacon
#

I meant of the general form.

rigid yoke
#

it wassss an expression

#

@snow beacon

snow beacon
#

So you can replace it with any other expression that does the same thing.

fluid tree
#

rhs_expr for lhs_expr1 in expr1 [for lhs_expr2 in iter_expr2 ...] [if if_expr1 ...]

[] means optional

#

That's the general form

rigid yoke
#

ohhh right

#

thank you!

#

wait i'll try that out really quickly

rigid yoke
#

[print(*[i for i in range(1,x+1)if x%i==0]) for x in range(1,101)] i'm 80% sure no improvements can be made in this method

stark fable
#

[print(*[i for i in range(1,x+1)if x%i==0])for x in range(1,101)]