#esoteric-python
1 messages ยท Page 105 of 1
yeup
!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]
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | Hello World
002 | Hello World
is it possible to make above print N times instead of 2
What made you feel the need to use shitty string formatting
It was bad enough before
!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)
@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
!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)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World
!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)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | Hello World
002 |
003 | Hello World
!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"
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World
!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:[lambdad:lambda f:[(f:=e(f))for e in reversed(d)]][str()==()](print,lambda :.)(....class.class(().str().class(),().class(),{'':d}))[0]
stdout <= disp("Hello World")
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | Hello World
002 | Hello World
aha I like this function I can print a thing as I use it
im just trying to understand 1% of it
!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"))))))
@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
so the number of times it prints is amount of recursive calls
thats a fun function
!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!"]]
@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!
there
I summoned the self reference from the land of the cursed
oh wait that's here
๐
!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])]
@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!
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])]
really fun stuff
@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!
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
i always forget thats a thing
!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()]
@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!
i wonder if there is a way to navigate throught _builtins_ stuff to create dictionary like that and make this even more complicated
it doesn't need to be complicated it just needs to show off the usefulness of self,disp and stdout
im be honest i never heard of disp till now
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
speaking of c++
but meh
i wonder if you can programn in pointers and stuff into python
@floral meteor :warning: Your eval job has completed with return code 0.
[No output]
huh
so that works
it prints, but just a newline
does hello world thing just get ignored or is it stored somewhere obscure i wonder
!e
print(', '.join(map(str, map(lambda x: x / 10, filter(lambda x: x % 10 == 0, range(1, 100))))))
@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
idk, the vanilla version is less readable
This is Perl-worthy
A glimpse without source code is more of a curse. My curiosity is piqued.
@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)
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.
i mean my join is a list method >.>
Even so.
how does that work wtf
__le__
it creates a new class using type with an le dunder
where does the <= come from
ohhhhhhhhhh
makes it support <=
crazy
!e
class Bruh:
def __init__(self):
self.self = self
def p():
print(self.self)
b = Bruh()
@lone scarab :warning: Your eval job has completed with return code 0.
[No output]
bruh
!e
class Bruh:
def __init__(self, arg1):
self.self = self
self.arg1 = arg1
def p():
print(self.self)
b = Bruh("hello world")
@lone scarab :warning: Your eval job has completed with return code 0.
[No output]
bruh
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")
@lone scarab :warning: Your eval job has completed with return code 0.
[No output]
!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()
@lone scarab :white_check_mark: Your eval job has completed with return code 0.
Hello, world!
bruh python
self is self and so is self therefore self is also self? makes self
๐ค
!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)))
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
hello world
Has someone tried to make brainf*ck's Hello World program in Python here yet?
!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)))
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
hello world
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')))())==_,_!=_,_<_,_>_,_<=_,_>=_,+_,-_,_+_,_-_,_*_)))
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
hello world
I made it work. That's why it works.
!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')))())==,!=,<,<,<=,>=,+,-,+,-,*,>))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World!
Couldn't you use << instead of <=
Why should they have?
!e ```py
4 << 5
@floral meteor :warning: Your eval job has completed with return code 0.
[No output]
@floral meteor :warning: Your eval job has completed with return code 0.
[No output]
ur genius
!eval
!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!*
!e print("Hello world!")
They seem to be copying the c++ syntax I think
!e import os os.system("dir")
@sturdy rune :warning: Your eval job has completed with return code 0.
[No output]
python bot is pretty secure
you can't really get anything
!e __import__("os").system("cd /etc/ && ls")
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
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
dang
idk im on my phone in the car
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
That's the gist of it, yes. There's a lot more like it in various parts of this channel.
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"
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
@floral meteor hm whats the difference between < <= and << in your lib
which one?
the c++ iostreams one
< 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
(And <<= is bitshifting assignment.)
#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")))
@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
!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")
@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!!!!!
!e s="""print('s=""'+'"'+s+'"'+'"";eval(s)')""";eval(s)
@forest hornet :white_check_mark: Your eval job has completed with return code 0.
s="""print('s=""'+'"'+s+'"'+'"";eval(s)')""";eval(s)
There's my quine
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
lol
Oh
eval is cheating
"[insert here] is cheating"
it kinda is though
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.
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
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
!e ```py
import random as r,string as s
print(''.join([r.choice(s.ascii_letters+s.digits) for i in range(8)]))
@drifting grove :white_check_mark: Your eval job has completed with return code 0.
CikHcMhl
@drifting grove you dont need the []
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)))
@drifting grove :white_check_mark: Your eval job has completed with return code 0.
US3AaI19
gen exprs ๐
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='')
@drifting grove :white_check_mark: Your eval job has completed with return code 0.
BCRKE13D
4 characters less then my previous one
!d random.choices
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)
!e
import random as r,string as s
print(*r.choices(s.ascii_letters+s.digits,k=8),end="")
@twilit grotto :white_check_mark: Your eval job has completed with return code 0.
0 s s X W X k c
oh wait, sep
!e ```py
import random as r,string as s
print(*r.choices(s.ascii_letters+s.digits,k=8),sep="")
@naive roost :white_check_mark: Your eval job has completed with return code 0.
B3O8hotz
interesting
!e ```py
import random as r,string as s
print(*r.sample(s.printable[:62]*8,8),sep="")
@drifting grove :white_check_mark: Your eval job has completed with return code 0.
wlINqWRp
!d string.printable
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").
!e
import random as r,string as s
print(''.join(r.sample(s.printable[:62]*8,8)))
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
RTZaIabI
!e print(import('string').printable)
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
001 | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
002 |
003 |
!e print(*filter(str.isalnum,map(chr,range(123))))
@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
!e py print(*__import__('random').choices([*filter(str.isalnum,map(chr,range(123)))],k=8),sep="")
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
QYB2PEOW
!e print (str.isalnum)
@drifting grove :white_check_mark: Your eval job has completed with return code 0.
<method 'isalnum' of 'str' objects>
!e print("1a.".isalnum())
@drifting grove :white_check_mark: Your eval job has completed with return code 0.
False
!d str.isalnum
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()`.
!d str.isalpha
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.
That looks spot on
Alright, time to improve my cursed File class
Common Vulnerabilities and Exposures (CVEยฎ) is a list of records โ each containing an identification number, a description, and at least one public reference โ for publicly known cybersecurity vulnerabilities. Assigned by CVE Numbering Authorities (CNAs) from around the world, use of CVE Records ensures confidence among parties when used to disc...
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))
@radiant anchor :warning: Your eval job has completed with return code 139 (SIGSEGV).
[No output]
Does @night quarry have every pip package installed lmao
It has the standard libraries, which includes ctypes, and a few other ones, like forbiddenfruit and maybe numpy?
it also has pandas
The common ones, I'd guess.
@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'
!e import colorama
@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'
!e import main
@floral meteor :warning: Your eval job has completed with return code 0.
[No output]
!e ```py
import main
print(dir(main))
@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 :white_check_mark: Your eval job has completed with return code 0.
['__annotations__', '__builtins__', '__doc__', '__loader__', '__main__', '__name__', '__package__', '__spec__']
!e ```py
import main
for this in dir(main): print(this, getattr(main,this))
@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
!e ```py
from main import builtins as _
for this in dir(): print(this, getattr(,this))
@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
!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}
@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
!e ```py
import main
print(420)
raise main.builtins.SystemExit(69)
@floral meteor please use #bot-commands for testing
@floral meteor :x: Your eval job has completed with return code 69.
420
k
@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
tf
@floral meteor :x: Your eval job has completed with return code 69.
420
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
@floral meteor :x: Your eval job has completed with return code 69.
420
this esoteric enough?
nice
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__())
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
/usr/local/lib/python3.9/_sitebuiltins.py
or does it?
!e ```py
filename="/usr/local/lib/python3.9/_sitebuiltins.py"
with open(filename,'r') as file:
print(file.read())
@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
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
@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'
no module named google haha
Hello there
@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.
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'
Please refer to #โ๏ฝhow-to-get-help to get help
This channel is kinda the opposite of that
sry
np
ohdamn my brother found that LOL
fr? noice
any chance u know him?
nope, saw the vuln on HN
ahh
he said ur in an irc
where he also hangs sometimes
@radiant anchor do u know oblivion then
uhhh I don't think so
but I do idle in a lot of IRCs
and a lot of discords, heh
heh fair enough, I am in a lot of places
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
contextlib.ContextDecorator
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:"))
have you ever heard of pep 8?
What's that?
!pep 8
!pep8
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.
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
yeah, amaras is right. I did not create this with the intension of following pep8 in mind.
!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()
@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
a
converts a RPN expression into bytecode!
there are easier ways, but we don't talk about that
Interesting...
!e
ฮป = "lambda"
print(ฮป)
@twilit grotto :white_check_mark: Your eval job has completed with return code 0.
lambda
oh
while True:
print("I am a masochist.")
```this channel in a nutshell
while~0 is cooler
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)
@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
!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)
@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
!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)
@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
How about a Hello World where the only thing you can do is call functions, e.g. range(int(), len(str(print())))? Any thoughts?
someone on here has written something like that but the whole thing uses dunders __these_things__ I think
I can try searching a bit
so there's this, although I'm not sure if it's exactly what you're looking for #esoteric-python message
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
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?
!e ```py
sum('a', 'b')
@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]
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
!e ```python
print(sum(list("hello"), type("",(),{"add":str})()))
@snow beacon :white_check_mark: Your eval job has completed with return code 0.
hello
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.
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
those + True, False and Ellipsis, but those ones are not really interesting (as you can get False from bool())
I think the challenge allows builtin functions only
True is also easy with callable(callable)
also, technically, __import__ is a builtin function
If we can construct an arbitrary string, we can construct "Hello, world!" and print it.
well, but what is a Hello, World! but a specific case of all possible programs?
True enough.
format might be useful
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...
I really need it to be in an iterable, but I think I've found a way to do that.
is dict(a=1, b=2) cheating?
I was trying to avoid that.
it does make it pretty easy
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.
there's probably a way of playing with True, False, pow and chr
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()
))
)
)
72 is len(sum(zip(chr(int())), tuple(dir(int()))))
wait, that's 71
nevermind, it's 72
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
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? 
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
hmm
do we have a way to subtract? 
since len(dir(tuple())) is 34 and we want 33 and 32

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.
locals(), globals() and vars() are all dicts, their dirs aren't going to be different
I realised that after I'd bothered typing them all out.

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.)
don't forget ```py
len(dir())
7
Those numbers are [7, 23, 25, 27, 33, 34, 43, 45, 47, 49, 56, 71, 75, 80, 87] for a nicer format.
alright, 33 is len(dir(property(type(int()))))
This one seems a little implementation-dependent, more so than usual.
you can get pretty much anything between 1x & 2x using len(repr(builtin))
interesting. I have: ```py
dir()
['annotations', 'builtins', 'doc', 'loader', 'name', 'package', 'spec']
In [1]: len(dir())
Out[1]: 22
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 :white_check_mark: Your eval job has completed with return code 0.
7
Okay, that's reasonably convincing.
7 seems to be the default
so if you work with a base interpreter (which you will do here), you can use 7
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.
101 is len(sum(zip(dir(classmethod(type(int()))), dir(int())), tuple(dir(list()))))
len(str(bool())) is 5, and so on
We might be able to use small numbers and pow.
won't be of much help indeed, as the hashes are salted, and the salts are not consistent between interpreter runs
e.g. 10**2.
and 2**5
Only for strings and bytestrings.
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))
if we can get 2
oh wait some of these aren't fns
which is quite easy ```py
len(str(len(dir(int()))))
2```
like copyright and credits
Or len(repr(str())).
oh, yeah
let's use that instead 
so pow(len(repr(str())), len(str(bool())))
is 32
you can get every nonzero power of 2 by chaining repr on a string :>
Well that would be a systematic way to get every number.
>>> pow(len(sum(zip(str(bool())),tuple(str(bool())))),len(repr(str())))
100``` here's 100
We have divmod, which is something.
We can just add arbitrary amounts of 1s together as well.
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
In [12]: len(str(hash(tuple())))
Out[12]: 19
In [25]: len(dir(Exception()))
Out[25]: 31
but you can as easily len(repr(enumerate))
(all contiguous ints from 13 to 28, then 30)
In [35]: len(str(type(PendingDeprecationWarning())))
Out[35]: 35
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())
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.
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
We needed 44, so that's good.
Which ones do we have?
[72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33]
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.
108, 109, 111, 114, 119. Alright.
111 is len(repr(frozenset(str(type(PendingDeprecationWarning())))))
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() )) ) )
@snow beacon :white_check_mark: Your eval job has completed with return code 0.
Hello, world!
Wow
OMG, how'd you do that? XD
that really is esoteric
You can do anything if you put your mind to it, apparently.
Amendment: you can do anything if you put your mind to it, unless that thing has to be done in two characters.
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.
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
sum is just concatenating the characters
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.
Oh I didn't know sum didn't work for characters
...what.
Which bit, the Hello World or the multiplication?
nothing
I saw something much further above
I didn't realise I was in history
nice challenge
best way to learn -- I thought sum only summed nums x3
so i know that this channel is basically dedicated to spaghettification but what about using so little characters that it becomes unreadable
We do golfing too.
can someone pin it? I think it's inspirational
within the character limit?
well no but thats the fun part
fair but the ability to demo somethin is a factor imo
like how I can't post my brainfk thing here directly
like there was a 10k char one made the other day that could still be made longer
hmm if we're going by max length then that's somethin
(it was also a oneliner)
The one I worked on is only on multiple lines for legibility. It would have been easier to write it on one line.
Yeah, i write most my shit in one line and just use pycharm reformatting
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"
)
)
only if you guys know discord.py
i would do
(lambda c: ...)(__import__("importlib").importmodule("discord.ext.commands").Bot(config stuff))
Anything this is actually nice, not esoteric
ty for the response, if it isnt esoteric, do you have a way of making it esoteric
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.
the esoteric bot lol
!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
@drifting grove :warning: Your eval job has completed with return code 0.
[No output]
Probably not the best version of this possible but I don't feel like making it better right now
hello world except no functions or methods can have any arguments
!e
import __hello__
@proper vault :white_check_mark: Your eval job has completed with return code 0.
Hello world!
There's a version without brackets or imports.
does it use python 2?
No, it goes something like```python
hello = lambda _: "Hello, world!"
@print
@hello
class _:0
!e ```python
@print
@lambda _:"Hello World"
class _:0
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
Hello World
!e ```py
import idlelib
print(idlelib.tree.BUTT)
@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'
!e py from idlelib import tree print(tree.BUTT)
@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
@floral meteor thats prob why it fails
lol
!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)])
@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']
i finally did it
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
oh god lol
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
which is how I've eventually gotten to stuff like this:

!e ```py
import sys as sus
sus.stderr.close()
sus.stdin.close()
sus.stdout.close()
p=print
p('p')
@floral meteor :warning: Your eval job has completed with return code 1.
[No output]
i mean, how is it gonna tell you what the error is, you closed the stream
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....
i absolutely hate and love that this was the first thing i see when i open this channel

# __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
So you basically just scripted your own terminal commands @floral meteor?
So esoteric is just writing the shortest code possible ain't it?
I made my own iostream syntax
Damn
no thats a branch of esoteric coding called golfing
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
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...
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
so something like the above would have to be manually generated?
Well you could generalize it somewhat
e.g. all binops
There might also be helpful enums in the ast module, not sure
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)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
<module>
awww
Well, if you compile "a binop b" you can probably retrieve the dunder
From the code object
!e ```py
try:str() + ...
except TypeError as e:print(e.traceback.tb_frame.f_back.f_code.co_name)
@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'
!eval ```py
def foo(a,b):
return a ** b
import dis
dis.show_code(foo)
@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
Maybe not
!e ```py
print(dir((lambda a,b:a+b).code))
@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']
!e print((lambda a,b:a+b).__code__.co_code)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
b'|\x00|\x01\x17\x00S\x00'
!e ```py
print([this.code.co_code for this in [
lambda a,b:a+b,lambda a,b:a-b,
lambda a,b:ab,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
]])
@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'
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:ab,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
]])
@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'
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)
]])
@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'
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
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
@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.
Ah, so the S 0xxx means return stack value?
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)
mmmmmm
how do I make a thingy such that when I supply bytecode and some inputs it returns the stuffs?
youre gonna need to be more specific than that
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
i still dont understand what your goal is
either a syntax to dunder translator or back
so like + to __add__?
!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)
@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
Systematically scrape the Data Model page :>
parsing Bytecode -> Dunders is easy
Bytecode that calls Dunders -> Bytecode that does it directly is hard as hell
0xa0 0x00 means load __add__ attribute of top of stack?
@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
!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))
@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
!e py import dis dis.dis(lambda b,c:b.__add__(c))
@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
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
and LOAD_FAST gets the input?
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]
I understand
as a rule, LOAD_* pushes a value onto the stack
ah, so that would include the locals &/| globals at the time of defining the lambda?
noice
@toxic jewel speaking of minecraft command blocks I made an actual fork bomb
and successfully fork bombed my pc
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
/command <shit here>
no shit it's the <shit here> i forgot
i think most of the actual <shit here> is js
also in command blocks you don't need the /
And this is esoteric python?
k i'll write it in python then
@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
hi
umm, can someone plz explain to me what this channel is for, I read the description too, but I didn't get it. sorry
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
hmm, so i have a string, and i need to do this task on it:
https://cdn.discordapp.com/attachments/807203846622543898/813369275410022410/Screenshot_from_2021-02-22_16-48-23.png
I have got a regex code for it, but i don't really like that, is there a smarter and short way of doing it?
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.
x < 'c' is a good trick to know
oo nice, never thought of this, i have used this before but something things don't pop up in your mind
more list comprehensions
i come here for my daily dose of insanity
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...
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 ๐ฉ
18 results ever, and I'm tempted to go through all of them, to see what kind of "refactoring" people from #esoteric-python do
any ideas on how i would make this more esoteric?
refactoring in this channel could have a very different meaning to anywhere else haha.
what even... @formal sandal wtf is this #esoteric-python message
oh my god
Sorry for the late response, I found the esoteric bot here
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")
)
what's this do
A discord bot
!pypi jishaku
Devon (Gorialis) R
=3.6.0
A discord.py extension including useful tools for bot development and debugging.
MIT
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])
look at the channel name, I guess
mudkip ๐ฅบ
Yeah ik, he's not in the discord anymore, so I couldn't give him credit
it seems to work as expected for me
maybe the bug is somewhere else in your code?
oops my bad sorry
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
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)
how often are you using print that you need to alias it?
Heya, what ways are there to find the package name of the running code?
i mean could you not just do:
n = print
?
@drifting grove
oh wait i think i might be misinterpreting your goals here, sorry.
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
are you trying to golf?
i'm writing a script that generates all possible lottery draws
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?
i'm avoiding too much testing
>>> 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
thanks i will try that
that combinations function may have made my entire script redundant
yep it has 
len([x for x in itertools.combinations(range(59), 6)])
It's ok :)
Don't worry about it
this is so confusing to me
i dont get how you call the lambda
@molten sky is the goal to see if all variables are distinct?
if so len(set(list_of_varialbes)) == len(list_of_variables)
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)
!e py _=((()==())+(()==())) __=(((_<<_)<<_)*_) __import__(('c%'[::(([]!=[])-(()==()))])*((_<<_)+(()==()))%((__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)<<_)+(_<<_))),(__+(((_<<_)<<_)+((_*_)+(()==())))),(__+(((_<<_)<<_)+((_<<_)+(_*_)))),(__+(((_<<_)<<_)+((_<<_)+(_*_)))),(__+(((_<<_)<<_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)*_)+((_<<_)+((_*_)+(_+(()==()))))))))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
Hello world!
i was finding the amount of possible draws in a lottery. For the UK lotto (6 balls from 1 to 59) it is about 45 million
so 1 in 45 mil chance of winning 
to possibly make it more efficient i could have done a comprehension in a tuple instead of a list
hi
hello ronbon
you could have just used combinatorics instead of generating them all...
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....
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
wow thanks for that, really well explained 
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
_>
@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
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))])
@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
now that's a nice chunky list
itertools.product(range(4), repeat=4)
although, i guess writing it out adds to the effect
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)
@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
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
well it's not being mutated by getitem, it's using setitem
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?
so like, integer keys?
aye, so it's just like a list, only squiggly and mutatable
i.e. a mutated rip-off of a list
i mean, that's just a worse list
!e py a=[1,2] a[2:] = 3, print(a)
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
[1, 2, 3]
!e ```py
import itertools
a4d={};a4d[0]=a4d;a4d[0][0][0][0]=0
print(a4d)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
{0: 0}
๐ค
!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]
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | [[[[[...]]]]]
002 | [[[[0]]]]
!e
i mean
L = []
L.append(L)
print(L)
@twilit grotto :white_check_mark: Your eval job has completed with return code 0.
[[...]]
!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)
@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
!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)
@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
@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]
!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]))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
(0.1, 0, 0.6, 1)
!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."""
@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.
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
@fossil estuary :white_check_mark: Your eval job has completed with return code 0.
False
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))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
True
you found one of the few numbers
few?
you can tell what it does
you mean one of the 10% of all integers?
its really meant for 16 digit numbers but ya
!e
_=()==();__=(_+_)+(_+_);___=((_+_)+(_+_)+(_+_)+(_+_)*(_+_)+(_+_)+(_+_)+(_+_));____="%c"*(_+_+_+_+_)%(((_+_)*((___*__+(__+__))//(_+_))),((_)*((___*__+(__+__)-(_+_+_)))),((_+_)*((___*__+(__+__)+(__))//(_+_))),((_+_)*((___*__+(__+__)+(__))//(_+_))),((_)*((___*__+(__+__)+(__+_+_+_)))))+" "+"%c"*(_+_+_+_+_)%(((_)*((___*__+(__+__)+(__+__+__+_+_+_)))),((_)*((___*__+(__+__)+(__)+(_+_+_)))),((_+_)*((___*__+(__+__)+(__)+(_+_+_)+(_+_+_))//(_+_))),((_+_)*((___*__+(__+__)+(__))//(_+_))),((_+_)*((___*__+(__+__)-(__))//(_+_))));print(____)
@fossil estuary :white_check_mark: Your eval job has completed with return code 0.
HELLO WORLD
one of the projects i made that took a long time
ah, yes, PyFuck
i could call it that
time to make it unicode characters :)
Did #coding=unicode_escape stop working recently? as i cant get it to work anymore
why not make only two variables, __=[];_=__==__?
It worked a few months back. But not anymore
# ~-~ coding: utf-8 ~-~
something like that now
maybe a module updated while you weren't looking
you could obfuscate that harder by instead of using length of underscore as the registry value, make an array as your registry, and code your registry values a bit 'softer'
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))
@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 :white_check_mark: Your eval job has completed with return code 0.
(2, 0)
Pro tip: you get an error in this channel, you are fucked and can't fix it(most of the time)
i can't remember which way around I wanted it
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
:(
!e ```py
print(7 .divmod(3))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
(2, 1)
10k? Damn
I have a script that makes oneliners
10k is waaaaay too much
The entire oneliner script, as a oneliner, is only 100k
@floral meteor it is literally int(7/3), 7 % 3 (which thereof you can infer 2 and a third)
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)]?
are you sure it's esoteric Python you want, and not asking a general help channel?
list(range(1, 101))
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
you code is incorrect, technically
wait so you can basically do
(lambda x: print(*[i for i in range(1, 101) if x % i == 0]))(10)
what's wrong with it
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?
the point is taking an iterable as input and spitting out the divisors
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
because divisors of x are always less than (or equal to) x
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?
How is it that people ask for help in a channel explicitly designed for esoteric stuff?
could you please ask your question in a general help channel? (see #โ๏ฝhow-to-get-help)
@ me if you want help from me in that channel, though, maybe I can help
sorry i'll go there
don't worry about that
code golf!
ohh wait i should probably clarify, my example uses 10 to show that my function takes 10 (int) but i would like it to take [x for x in range(1,101)] so it gets all the divisors
i did solve it (albeit badly), here's my code:
okay, makes sense
[(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
You either make it have a backward link or just eliminate the problem
You can cut the whole lambda out lol
oh wait really?
You define a function only to immediately call it.
ah
oops i was replying to this
how would i cut the lambda out
You have something in the form (lambda x: ...)(x) which is equivalent to ....
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
Do you know the general form for list comprehensions?
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>]
In the old version, what part was the (lambda x:print(*[i for i in range(1,x+1) if x%i==0]))(x)?
[print(*[i for i in range(1,x+1) if x%i==0]) for x in range(1,101)]
I meant of the general form.
So you can replace it with any other expression that does the same thing.
rhs_expr for lhs_expr1 in expr1 [for lhs_expr2 in iter_expr2 ...] [if if_expr1 ...]
[] means optional
That's the general form
[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
[print(*[i for i in range(1,x+1)if x%i==0])for x in range(1,101)]


