#esoteric-python
1 messages ยท Page 103 of 1
@plucky wedge :white_check_mark: Your eval job has completed with return code 0.
3
lol
I got at most a 6 for now, I'm going to do a little statistical analysis
!e
print(chr((3).__add__(__import__("operator").floordiv(__import__("random").randint(1,10000000), __import__("random").randint(1,1000000)))))
@plucky wedge :white_check_mark: Your eval job has completed with return code 0.
fun
ok, out of 10_000_000 such numbers, I got an average of around 10.56, a standard deviation of about 1215, with a median of 3, a 75th-percentile of 4, 90th percentile of 7, 99th percentile of 52, and maximum of 1904107. wow, that's quite clumped around 3
are u talking to me?
I just wanted to do a quick analysis of the results of your code ๐
interesting phenomenon: the standard deviation increases as you remove the smallest elements. that's quite an interesting distribution you got us ๐
im not sure i know what that means
I still have yet to take anything on statistics so
@bitter iris it all stems from the fact that LOAD_CONST doesnt do bounds check
;/
so you can construct a fake bytearray object to get r/w to pythons entire address space
wow, that's... interesting to say the least (talking to chilaxan)
!e ```py
def sizeof(obj):
return type(obj).sizeof(obj)
TUPLE_HEADER = sizeof(())
BYTES_HEADER = sizeof(b'') - 1
PTR_SIZE = sizeof((0,)) - TUPLE_HEADER
MAX_INT = (1 << PTR_SIZE * 8 - 1) - 1
def load_addr(addr):
magic = lambda:None
b_addr = addr.to_bytes(PTR_SIZE, 'little')
offset = id(b_addr) + BYTES_HEADER
offset -= id(magic.code.co_consts) + TUPLE_HEADER
offset //= PTR_SIZE
if offset < 0: # overflow offset to convert to unsigned
offset += 0xffffffff + 1
co_code = bytes((0x64, offset & 0xff))
offset >>= 8
while offset > 0:
co_code = bytes((0x90, offset & 0xff)) + co_code
offset >>= 8
co_code += bytes((0x53, 0))
magic.code = magic.code.replace(
co_code=co_code
)
return magic()
memory_backing = b''.join(n.to_bytes(PTR_SIZE, 'little') for n in (
1,
id(bytearray),
MAX_INT,
0, 0, 0, 0
))
mem = load_addr(id(memory_backing) + BYTES_HEADER)
mem is now a bytearray pointing to the entire address space```
@rugged sparrow :warning: Your eval job has completed with return code 0.
[No output]
@naive roost that is the basic construct
oh, right. I don't understand much of that, though
dafq
that's what you get when you delve in CPython's internals, but in Python
this is too high low level for me
why print and not (__import__("sys").stdout.write())
made my hello world statement longer btw
!e
(
(_:=lambda _:(_ := _.__add__(__name__.__len__().__bool__().__int__())),
(__import__("sys").stdout.write(
chr(__:=[_(x) for x in range(ord(chr(72)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(101)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(108)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(108)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(111)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(44)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(32)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(87)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(111)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(114)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(108)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(100)).__int__())][-(__debug__.__int__())]).__add__(
chr(__:=[_(x) for x in range(ord(chr(33)).__int__())][-(__debug__.__int__())])
))))))))))))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
longer, but short enough to paste in here for immediate eval
tbh that's a good goal
can aswell be condensed down into a single line as its a tuple
!e
((_:=lambda _:(_ := _.__add__(__name__.__len__().__bool__().__int__())),(__import__("sys").stdout.write(chr(__:=[_(x) for x in range(ord(chr(72)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(101)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(108)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(108)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(111)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(44)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(32)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(87)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(111)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(114)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(108)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(100)).__int__())][-(__debug__.__int__())]).__add__(chr(__:=[_(x) for x in range(ord(chr(33)).__int__())][-(__debug__.__int__())])))))))))))))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
probably my best esoteric work
why __import__("sys").stdout.write and not __import__("os").fdopen(1,"w").write
fair enough
!e
(
_ := lambda message: print(message),
_("i wonder if this works"))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
i wonder if this works
basially, what cityshow is doing is _ = print
got it
@sick hound :white_check_mark: Your eval job has completed with return code 0.
hello world
wait can I just start using _ for varnames everywhere
๐
ngl i really want to try to create a really basic python obfuscator
anyone know how to collapse cells in jupytr notebook?
i remember doing it once and I forgot..
alright y'all, we need an esoteric python implementation for this
more srsly tho idk :c
lol its all good back to google
lol
ugh i can collapse the output cell but not input
hey quick question
since there's an sys.stdout.write()
is there an input version of it?
nvm
there's a sys.stdin.readline()
fuckk i don't want to write an expression parser
!e
[a:=__name__.__len__().__bool__().__int__(), __import__("sys").stdout.write(a.__str__().__add__(chr(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())))))]```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
1
(pretend "sys" is chr(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__()...)
equivalent code is
a = 1
print(a)```
actually here
!e
[a:=__name__.__len__().__bool__().__int__(), b:=__name__.__len__().__bool__().__int__(), c:=a.__add__(b), __import__('sys').stdout.write(c.__str__().__add__(chr(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())))))]```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
2
(sys is here cause otherwise discord would throw a fit)
equivalent code is
a = 1
b = 1
c = a + b
print(c)```
I find it interesting how you made the print statement so verbose
I wonder if the a+b part can be made into a bunch of 1+1s
do it the brainfuck way I guess
yeah either that or more lambdas https://en.wikipedia.org/wiki/Church_encoding#Church_numerals
powerful
I think there's the AST library.
it is literally a bunch of 1+1s
do everything with a series of increments ofc
it is literally that
lmfao
but with some slight optimizations
remove the optimizations and further obfuscate
only way to progress ofc
no like i don't want it too big
cause like
it wont fit on discord then
yeah, won't be as easy to demo it
oh fair enough
ohh most of all that is for \n, wow
okee I get this then
?
@lavish shore wdym
!e
[a:=__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()), b:=__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()), c:=a.__add__(b), __import__('sys').stdout.write(c.__str__().__add__(chr(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())))))]
@sick hound :white_check_mark: Your eval job has completed with return code 0.
7
it's just that the add is c:=a.add(b)
?
nvm
!e
[a:=__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__doc__.__bool__().__int__()), b:=__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()))).__add__(__name__.__len__().__bool__().__int__()), c:=a.__add__(b), __import__('sys').stdout.write(c.__str__().__add__(chr(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())))))]```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
73
ooh
if given the vars, i could also replace all of the vars with _
and bool
now i need to write conditionals
and loops
and boom turing complete
sighs
ya is tedious
that it is
i have a thing to convert string -> dunder level encoding
and theoretically i could wrap that in an exec(eval())
but i can only work with ints
:c
import unittest
from mixin.decorators import inject
from mixin.entities import At
from mixin.enums import InjectionPoint
def head_target():
print("head_target")
return 10
def tail_target():
print("tail_target")
return 10
def return_target(check: bool):
print("return_target")
if check:
return 100
return 30
class InjectTestCase(unittest.TestCase):
def info(self, tgt):
# disassemble(tgt.__code__)
pass
@staticmethod
@inject(head_target, At(InjectionPoint.HEAD), True)
def inject_head_cancel(cbr):
print("hi from head cancel")
cbr.set_return(2)
@staticmethod
@inject(head_target, At(InjectionPoint.HEAD))
def inject_head(cb):
print("hi from head")
def test_head(self):
self.info(head_target)
result = head_target()
self.assertEqual(2, result)
@staticmethod
@inject(tail_target, At(InjectionPoint.TAIL))
def inject_tail(cb):
print("hi from tail")
@staticmethod
@inject(tail_target, At(InjectionPoint.TAIL), True)
def inject_tail_cancel(cbr):
print("hi from tail cancel")
cbr.set_return(cbr.returned_value + 2)
def test_tail(self):
self.info(tail_target)
result = tail_target()
self.assertEqual(12, result)
@staticmethod
@inject(return_target, At(InjectionPoint.RETURN), True)
def inject_return_cancel(cbr):
print("hi from return cancel")
cbr.set_return(cbr.returned_value * 2)
def test_return(self):
self.info(return_target)
self.assertEqual(200, return_target(True))
self.assertEqual(60, return_target(False))
if __name__ == '__main__':
unittest.main()
this works somehow
cbr stands for CallbackReturnable in case anyone's wondering
the fuck
never used unittest so idk what "the usual" is for that
oh wait
imagine for bool methods just injecting a negator at the end
!e
[a:=[_:=__import__('sys'), _.stdout.write(chr(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()))).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())))), _.stdin.readline()][__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())], __import__('sys').stdout.write(a.__str__().__add__(chr(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__pow__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__()).__add__(__name__.__len__().__bool__().__int__())).__add__(__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())))))]```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
e
good enough
ehhh it's better when everything are dunders
I can cook up a fully dunder print function for you
give me a bit
!e py __builtins__.__dict__[__builtins__.__dir__()[().__class__.__name__.__len__().__rmul__(__debug__.__add__(__debug__)).__rmul__({}.__class__.__name__.__len__())]]("Hello, World")
@tribal moon :white_check_mark: Your eval job has completed with return code 0.
Hello, World
here you go
__builtins__.__dict__[__builtins__.__dir__()[().__class__.__name__.__len__().__rmul__(__debug__.__add__(__debug__)).__rmul__({}.__class__.__name__.__len__())]](anything in here to call it)```
any way to overly complicate "return" ?
i see stdout.write
i like it
!e
(
_ := lambda _: (__ := ({"testprint": "(__import__(\"sys\").stdout.write(f"{_}"))"}))
_ := lambda _: (___ := lambda _: __["testprint"])
)
@sudden willow :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | _ := lambda _: (__ := ({"testprint": "(__import__(\"sys\").stdout.write(f"{_}"))"}))
003 | ^
004 | SyntaxError: invalid syntax
im not sure
brb
!e
((_ := {"cout": "__import__(\"sys\").stdout.write(f\"test\")"}), _ := lambda _: exec(_["cout"]))
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
huh
cause you didn't call anything
!e ((_ := {"cout": "import("sys").stdout.write(f"test")"}), __ := lambda: exec(_["cout"]), __())
@sick hound :white_check_mark: Your eval job has completed with return code 0.
test
give me terrible advice
scroll up for inspiration
class C: ... is just sugar for type("C", ...), and we don't want sugar
I'm guessing I should go through the "built-in functions" for https://docs.python.org/3/library/functions.html ?
def foo(bar): source is just sugar for foo = types.FunctionType(types.CodeType(..., compile("source", ...)), ...), and we don't want sugar
wat.
Python is just sugar for C, and we don't want sugar
lmfaoo
c is just sugar for machine code, and we don't want sugar
obligatory
https://xkcd.com/378/
Binary is just sugar for computers, and we don't want binary
lmfao
actually technically that's false
more like binary is just syntaxic sugar for transistors, and we don't want sugar
well you can use terrible electric components so that 0 and 1 aren't even clear
digital is sugar for analog?
And analog is sugar for information
not sure if there's an "analog computer" yet
An analog computer or analogue computer is a type of computer that uses the continuously changeable aspects of physical phenomena such as electrical, mechanical, or hydraulic quantities to model the problem being solved. In contrast, digital computers represent varying quantities symbolically and by discrete values of both time and amplitude.
An...
this thing?
also logic gates
chain enough of them together
and boom
oh no
And they said this channel couldn't get more cursed.
Next challenge:
. You are given an infinite amount of NAND gates
. Make GTA V
NAND aren't turing-complete, strictly speaking
but it IS a universal gate
anyways, python frickery
I mean, nand2tetris already gives you a very simplified feel of that
Hmm...
I do wonder however, what it would be like if any sort of abstraction was forbidden past and, not and or gates
Probably a huge mess
probably
pretty much, yeah
It'd be like zooming into one of these maybe https://en.wikipedia.org/wiki/Very_Large_Scale_Integration
!e
# Task: find the predecessor of a positive integer
# E.g. pred(1) = 0, pred(8) = 7
class Verify:
def __init__(self, n, i):
self.n = n
self.i = i
def __add__(self, x):
return 1 if self.i + x == self.n else 0
def pred(n):
verifiers = []
for i in range(n):
verifiers.append(Verify(n, i))
pred_int = 0
for i in range(n):
if verifiers[i] + 1:
pred_int = i
return pred_int
print(pred(1))
print(pred(100))
@lavish shore :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 99
some totally efficient code I wrote a month or two ago
@quick wing Please don't dump random images, especially in on-topic channels
!e
type('While',(),{"__iter__": lambda self: self, "__next__": lambda self: "Infinite", "__call__": lambda self: _ for _ in self()})()()
@elfin onyx :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | type('While',(),{"__iter__": lambda self: self, "__next__": lambda self: "Infinite", "__call__": lambda self: _ for _ in self()})()()
003 | ^
004 | SyntaxError: invalid syntax
can someone help me implement this
I think you have to put parenthesis around the lambda expressions
ooh
!e
(type('While',(),{"__iter__": (lambda self: self), "__next__": lambda self: ("Infinite"), "__call__":lambda self: [... for _ in self()]}))()()
Hmmm why does this give me recursion error rather than the bot saying it ran out of memory?
@elfin onyx :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 "<string>", line 1, in <lambda>
004 | File "<string>", line 1, in <lambda>
005 | File "<string>", line 1, in <lambda>
006 | [Previous line repeated 496 more times]
007 | RecursionError: maximum recursion depth exceeded
got it
!e
(type('While',(),{"__iter__": (lambda self: self), "__next__": lambda self: ("Infinite"), "__call__":lambda self:([_ for _ in self.__class__()])}))()()
@elfin onyx :warning: Your eval job timed out or ran out of memory.
[No output]
!e
print("\n".join((type('While',(),{"__iter__": (lambda self: self), "__next__": lambda self: ("Infinite"), "__call__":lambda self:(("Hello, World!" for _ in self.__class__()))}))()()))
@elfin onyx :warning: Your eval job timed out or ran out of memory.
[No output]
why did this give no output??
timed out or ran out of memory
ye that kinda makes sense i think while joining it ran out of memory
what does that do
i ran it on my computer it uses 100mb of memory a second
because esoteric Python
wouldn't that cause a memoryerror
!e
("e" for _ in iter(int, 1))
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
guess not
@naive roost :warning: Your eval job timed out or ran out of memory.
[No output]
once you start evaluating an infinite iterator, you run out of memory
tuples are so useful
oh wait i didn't put any variables in the list
!e
(
_ := ["hi", ":P"],
_ := [(_.append(__), _.pop(0), print("t")) for __ in _]
)
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
001 | t
002 | t
i don't think you can have a inf while loop w/o running out of memory in python using list compr :c
!e [print(i) for i in iter(int, 1)]
@sick hound :x: Your eval job timed out or ran out of memory.
001 | 0
002 | 0
003 | 0
004 | 0
005 | 0
006 | 0
007 | 0
008 | 0
009 | 0
010 | 0
011 | 0
... (truncated - too many lines)
Full output: too long to upload
you can't have an infinite list without running out of memory
just by the mere fact that a list stores pointers to the elements, which are on the heap (meaning they have to be in memory, and pointers to them are definitely in memory too)
nvm
def pad_nop(instructions: List[Instruction]) -> List[Instruction]:
return [x for i in instructions for x in [_instruction("NOP", 0), i]]
``` is there a better way to do this?
it basically adds a NOP before each instruction
that's pretty cool, tho I think that'd make a list of lists
also @grave rover what do you mean by a "better way"
do u want a shorter way, or a more obfuscated way, for example?
@grave rover you can use zip
def pad_nop(instructions):
return sum([*zip(instructions, iter(lambda:_instruction("NOP", 0),0))],())
```
That should work I think
class Test(AccessControl):
internal_method: PRIVATE
def internal_method(self):
return 'value'
def public_method(self):
return self.internal_method()
>>> t = Test()
>>> t.internal_method()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/chilaxan/Desktop/Coding/python/access_control/access_control.py", line 98, in get
check_access_prot(protections, cls, self, frame)
File "/Users/chilaxan/Desktop/Coding/python/access_control/access_control.py", line 91, in check_access_prot
raise PrivateAccessError(read)
__main__.PrivateAccessError: attempted to read PRIVATE value
>>> t.public_method()
'value'
>>> ``` i added class variable access protection to python
new PEP when?
lmao
i added all the ones from java that made sense DEFAULT = 1 << 0 PROTECTED = 1 << 1 PUBLIC = 1 << 2 PRIVATE = 1 << 3 FINAL = 1 << 4 STATIC = 1 << 5
you can combine any of the first 4 with the last 2 but static is still a bit weird
if anyone wants to check out the code just ping me
it seems somehow you added a type annotation but that annotation actually does something during runtime? confused
!e ```py
class Foo:
v: int
print(Foo.annotations)```
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
{'v': <class 'int'>}
you can get the annotations at runtime like that
ahh I'm still learning bout some builtins that I never previously had to use
like id, getattr
ig dunders come next
notices compile()
๐ค
!e ```py
list(iter(set,0))
no, but this will
@sick hound :warning: Your eval job timed out or ran out of memory.
[No output]
@rugged sparrow hey, looks great! mind sharing some sources? also, I've come to tell that using cls.__annotations__ or function.__annotations__ is not as good as typing.get_type_hints(cls) or typing.get_type_hints(function) respectively
and even more so, because the latter were the things intended for use
typing.get_type_hints just gets __annotations__ and does some extra parsing to handle recursive type hints
I tend to use __annotations__ because it has the raw values from the class body
>>> my_tuple.append(3)
(3,)
>>> my_tuple.append(16)
(3, 16)```
class tuple(tuple):
def __init__(self):
self.self = self
def append(self, item, /):
self.self = (*self.self, item)
return self.self
what happens when you do such thing as self.self = self
hm, what could be wrong here?
(left: bytecode in function, right: expected stack)
ignore the NOPs, those are purely to indicate injected instructions
hi i have a problem with my tcp chat room it works fine on a local network but i cant get it to run outside my network
can you help me
this is probably one of the worst places to ask for help lmfao
yup
except for things like what I asked for
oh wait i see
the parameter to that isn't the number of arguments but flags
this JTP guy posted this question on every channel here
or is it
uhhh
wait no it is the number of args
oh my god I knew i'd seen this before
co_nlocals was the wrong size
can someone explain to me why co_nlocals is useful if you could also just check PyTuple_GET_SIZE(co_varnames)
df = pd.read_csv("")
using this to get csv from a directory and using it in a panda dataframe.
what i want to do is, get all csv inside that directory in a list or something, so i can run a loop in the above function. and use them 1 by 1.
all files has similar initial naming.
For eg: xyz- is common below
xyz-abc
xyz-def
xyz-abc2
!e
l = ["abc", "def", "def2"]
for i in l:
print(f"xyz-{i}")
@restive rampart :white_check_mark: Your eval job has completed with return code 0.
001 | xyz-abc
002 | xyz-def
003 | xyz-def2
This was eg.
File name are bigger and there is 40-50 CSV.
Something like
xyz-* I am looking for but unable to find the solution.
Look into this
you can loop through all the available .csv files in a directory
using glob
wanted to post here an esoteric C code but then I read the channel's name.
actually it's not so esoteric, just compact and very optimized
I mean that's what this channel can be too
Maybe not the optimized part but...
this channel is specifically for python
im sure a bit of C code never hurt anyone @cloud fossil
a bit of C code was deleted from this channel, probably by lakmatiol
:/
!e
from random import choice
from math import log
def basic_num(num):
a = ["__name__.__len__().__bool__()"]
c = ["__doc__.__bool__().__int__()"]
if num == 0:
return choice(c)
b = [choice(a) for _ in range(num)]
return b.pop(0) + ''.join(map(lambda x: f".__add__({x})", b))
def optimised_num(num):
a = []
while num > 5:
pows = [int(log(num) / log(i)) for i in range(2, 6)]
nums = [(i + 2) ** j for i, j in enumerate(pows)]
max_ = max(nums)
num -= max_
i = nums.index(max_)
a.append(f"{optimised_num(i + 2)}.__pow__({optimised_num(pows[i])})")
a.append(basic_num(num))
return a.pop(0) + ''.join(map(lambda x: f".__add__({x})", a))
def convert_string(word):
a = [f"chr({optimised_num(ord(i))})" for i in word]
return a.pop(0) + ''.join(map(lambda x: f".__add__({x})", a))
a = convert_string("print('Hello World!')")
print(eval(a))
print(a)
@ornate spire :white_check_mark: Your eval job has completed with return code 0.
001 | print('Hello World!')
002 | chr(__name__.__len__().__bool__().__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()).__pow__(__name__.__len__().__bool__().__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__())).__add__(__name__.__len__().__bool__().__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()).__pow__(__name__.__len__().__bool__().__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()))).__add__(__name__.__len__().__bool__().__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()))).__add__(chr(__name__.__len__().__bool__().__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()).__pow__(__name__.__len__().__bool__().__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__()).__add__(__name__.__len__().__bool__())).__add__(__name__.__len__().__bo
... (truncated - too long)
Full output: too long to upload
hey that's my dunder thing
!e
@rugged sparrow hey, uhm, I asked already but perhaps need to ask again; wanted to peek at the source of access_control thingy you were working on yesterday
@marsh void I'm gonna guess the parent constructor does a check for property annotations, turns them into propertys and checks the stack in the setter/getter
it's basically the same trick I used for generics :P
@marsh void https://paste.pythondiscord.com/ukadibasoj.py
to make a controlled class make it inherit from AccessControl
and put all the attributes you want protected at the top as annotations
like py class Foo(AccessControl): private: PRIVATE protected: PROTECTED | FINAL
making methods protected works, as does making protected @propertys but i wouldnt use it in production ever
+ might look better than |.
i did it like that cause i use them as flags if prot & PRIVATE: ...
so it made sense to use |
And I suppose with + it's no longer idempotent.
to be fair + does work but i think | is clearer imo
PROTECTED + PROTECTED = PUBLIC, which might not be for the best.
yea that wouldnt be great
to be fair you can change the protections on an attribute by setting cls.attr.fget.__closure__[idx of int closure].cell_contents
I've been thinking of this challenge where you have flags, but you bit-and them instead of using bit-or
so PROTECTED | FINAL -> PROTECTED & FINAL
each combination needs to still be unique, but their actual values don't mind
what would be the rules for generating such flags' values?
They'd just be ~ of the normal flags.
1101 instead of 0010 effectively.
It's De Morgan's Law.
but then how can you check if a value includes a certain flag
You'd OR it with a certain flag, then NOT it, I think.
flags & my_flag != 0?
flags | my_flag != -1
nope: ```py
((~a & ~b) | c)
-7
((~a & ~b & ~c) | c)
-7
You might need to use ~c.
This symmetry is De Morgan's Law. It's basically "A or B is not(not A and not B)".
That's for Boolean algebra, but it works for sets and binary too.
anyways imma head to bed, got a lot of bytecode hacking done today 
!e ```py
print("not rly useful but still cursed\n", ([].len().bool().str().len()).add([1].len().bool().str().len()).truediv(2))
@terse mortar :white_check_mark: Your eval job has completed with return code 0.
001 | not rly useful but still cursed
002 |
003 | 4.5
why not this
!e
__import__("sys").stdout.write((([].__len__().__bool__().__str__().__len__()).__add__([__debug__.__bool__().__int__()].__len__().__bool__().__str__().__len__()).__truediv__(__debug__.__bool__().__int__().__add__(__debug__.__bool__().__int__()))).__str__())
o
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
4.5
what's __truediv__ ?
__truediv__ is called when the / operator is used... a/b, __floordiv__ is called when the // operator is used... a//b. For integers and floats this is regular division but __floordiv__ returns the "floored" result
I found this on stack overflow:
import re
def findWholeWord(w):
return re.compile(r'\b({0})\b'.format(w), flags=re.IGNORECASE).search
findWholeWord('seek')('those who seek shall find') # -> <match object>
findWholeWord('word')('swordsmith') # -> None
Does anyone know what this functionality is called where you call a function like this function(parameter)(more parameters?). Not sure if its really esoteric but i never seen it before and would like to learn more about it.
to an extent, it could be called currying
but really, it's just using the fact python has first class functions
thanks man, Now i can look up how it works ๐
a function can return another function
a simpler example would be
def fun():
print('hello')
def bar():
return fun
bar()()
# After mixins:
# 'head inject'
# 'head cancel'
# => return 2
def head_target():
print("head_target")
@inject(head_target, at=At(InjectionPoint.HEAD), cancellable=True)
def inject_head_cancel(cir: CallbackInfoReturnable):
print("head cancel")
cir.set_return(2)
@inject(head_target, at=At(InjectionPoint.HEAD),
priority=10) # Run before cancel
def inject_head(ci: CallbackInfo):
print("head inject")
``` this now works, nice

shhh
I've already made sure this won't segfault on marshal-generated code, dw
I can also inject at any return, before loading a certain constant, and at the last return only
injecting before function calls is a bit more difficult sadly
since i need to quite literally look at how the stack behaves
!e py __builtins__.__dict__[__builtins__.__dir__()[().__class__.__name__.__len__().__rmul__(__debug__.__add__(__debug__)).__rmul__({}.__class__.__name__.__len__())]]((([].__len__().__bool__().__str__().__len__()).__add__([__debug__.__bool__().__int__()].__len__().__bool__().__str__().__len__()).__truediv__(__debug__.__bool__().__int__().__add__(__debug__.__bool__().__int__()))).__str__()) I made what I did yesterday worse
@terse mortar :white_check_mark: Your eval job has completed with return code 0.
4.5
an empty list
@terse mortar :white_check_mark: Your eval job has completed with return code 0.
0
!e ```py
print([].len().bool().str().len())
@terse mortar :white_check_mark: Your eval job has completed with return code 0.
5
!e print(doc.bool())
right, but i need to be able to get true aswell
!e print(name.len().bool())
ahh cool
wait i need to try somethign
!e print(doc.bool().invert())
the fuck
!e print(bin(False))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
0b0
invert is just the number number * -2 I think
!e
x = 2
print(bin(x))
print(bin(x.__invert__()))```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 0b10
002 | -0b11
dafq
ok ima just leave this here
!e ```py
for x in (type('While',(),{'iter': lambda self: self, 'next': lambda self: "Infinite"}))():(_:='One Piece Is The Greatest');builtins.dict[builtins.dir()[().class.name.len().rmul(debug.add(debug)).rmul({}.class.name.len())]]("".join(chr(ord(__)) for __ in _))
@terse mortar :x: Your eval job timed out or ran out of memory.
001 | One Piece Is The Greatest
002 | One Piece Is The Greatest
003 | One Piece Is The Greatest
004 | One Piece Is The Greatest
005 | One Piece Is The Greatest
006 | One Piece Is The Greatest
007 | One Piece Is The Greatest
008 | One Piece Is The Greatest
009 | One Piece Is The Greatest
010 | One Piece Is The Greatest
011 | One Piece Is The Greatest
... (truncated - too many lines)
Full output: too long to upload
oneliner cursed thingy
!e for x in __import__("itertools").count(1): print("eee")
we have a lambda one liner, dunder one linder, and one liner, what else?
@sick hound :x: Your eval job timed out or ran out of memory.
001 | eee
002 | eee
003 | eee
004 | eee
005 | eee
006 | eee
007 | eee
008 | eee
009 | eee
010 | eee
011 | eee
... (truncated - too many lines)
Full output: too long to upload
kek
is there any other way to make an obfuscator
we already have dunders and lambdas done
yes
what else?
exec(eval(str of program))
wont that just return none?
str of the program
that's not obfuscated
close enough there's too many fucking dunders to count
!e exec(eval("print('Hello, World!')"))
@terse mortar :x: Your eval job has completed with return code 1.
001 | Hello, World!
002 | Traceback (most recent call last):
003 | File "<string>", line 1, in <module>
004 | TypeError: exec() arg 1 must be a string, bytes or code object
Hey @sick hound!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
also don't use exec
fuck
use py __builtins__.__dict__[__builtins__.__dir__()[(lambda _, __, ___, ____, _____, ______, _______, ________, _________, __________: _).__code__.co_nlocals*(lambda _, __: _).__code__.co_nlocals]]
this is better
i made a dunder list the other day
idk
I can generate it for you
but this
but it's gonna be long
dude why
i forgot what channel i was in LOL
lmfao
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
https://paste.pythondiscord.com/yovilefoqo.py @sick hound
It is fairly on topic
no ik lol
!e
for x in (type('While',(),{'__iter__': lambda self: self, '__next__': lambda self: "Infinite"}))():(_:='One Piece Is The Greatest');__builtins__.__dict__[__builtins__.__dir__()[().__class__.__name__.__len__().__rmul__(__debug__.__add__(__debug__)).__rmul__({}.__class__.__name__.__len__())]]("".join(chr(ord(__)) for __ in _))
@elfin onyx :x: Your eval job timed out or ran out of memory.
001 | One Piece Is The Greatest
002 | One Piece Is The Greatest
003 | One Piece Is The Greatest
004 | One Piece Is The Greatest
005 | One Piece Is The Greatest
006 | One Piece Is The Greatest
007 | One Piece Is The Greatest
008 | One Piece Is The Greatest
009 | One Piece Is The Greatest
010 | One Piece Is The Greatest
011 | One Piece Is The Greatest
... (truncated - too many lines)
Full output: too long to upload
is there a way to use self in a class with type
because isn't the first argument the self part?
umm, what exactly does that do?
a=input("input a number: " )
a = int(a)
print(a)
a = a + 1
print(a)```
dont use sys for print, use this ```py
builtins.dict[builtins.dir()[().class.name.len().rmul(debug.add(debug)).rmul({}.class.name.len())]]("What you print")
lol
kek
i could also do that one chr
thing
but i'm lazy
but it's literally 1 copy paste
I think I wrote one for chr
yeah, arent we all
it's all the way up now
just chr
do you wanna know how to write dunder keywords
um what
it's pretty easy
?
>>> __builtins__.__dir__().index("chr")
14
>>> __debug__.__add__(__debug__).__rmul__(__debug__.__add__(__debug__)).__add__({__debug__}.__class__.__name__.__len__()).__rmul__(__debug__.__add__(__debug__))
14
>>> __builtins__.__dict__[__builtins__.__dir__()[__debug__.__add__(__debug__).__rmul__(__debug__.__add__(__debug__)).__add__({__debug__}.__class__.__name__.__len__()).__rmul__(__debug__.__add__(__debug__))]]
<built-in function chr>
>>>
like that
!e py print("Dunder Chr of A") print(__builtins__.__dict__[__builtins__.__dir__()[__debug__.__add__(__debug__).__rmul__(__debug__.__add__(__debug__)).__add__({__debug__}.__class__.__name__.__len__()).__rmul__(__debug__.__add__(__debug__))]](65))
@tribal moon :white_check_mark: Your eval job has completed with return code 0.
001 | Dunder Chr of A
002 | A
!e ```py
builtins.dictbuiltins.dir()[().class.name.len().rmul(debug.add(debug)).rmul({}.class.name.len())]
this isnt that bad but here
@terse mortar :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
ohh
that's how it works
it encodes it in base64 by the way
because all it can do is letters
but it's really bad it takes up a lot of space
a simple hello world program in Oof's dunder generator would be like a million lines in this one lol
I have to optimize it
optimize a deoptimizer
LOL
better yet: run the source code in the generator itself!
also i really hope you arent running that on your real pc
wack
I am lol
I don't run it anymore
it's too bad
like a tic tac toe program took 20k lines
!e
(lambda i: [print(chr(x),end='') for x in (lambda i=i: [globals().update({"h":(lambda _=(i[-1]+i[2]): (_*_)+i[3])()}) or h,h - i[2],globals().update({"l":h + i[3]}) or l,l,globals().update({"o":l + i[2]}) or o,(i[-1] + i[0]) * 4,o + (i[3] * 2),o,o + i[2],l,h - i[3],i[4] * 2])()])([_.__code__.co_argcount for _ in ((lambda _: None),(lambda _, __: None),(lambda _, __, ___: None),(lambda _, __, ___, ____: None),(lambda _, __, ___, ____, _____: None),(lambda _, __, ___, ____, _____, ______: None),(lambda _, __, ___, ____, _____, ______, _______: None))])
@shy remnant :white_check_mark: Your eval job has completed with return code 0.
hello world
wtf
!e
(lambda i: [print(chr(x),end='') for x in (lambda i=i: [globals().update({"h":(lambda _=(i[-1]+i[2]): (_*_)+i[3])()}) or h,h - i[2],globals().update({"l":h + i[3]}) or l,l,globals().update({"o":l + i[2]}) or o,(i[-1] + i[0]) * 4,o + (i[3] * 2),o,o + i[2],l,h - i[3],i[4] * 2])()])([_.__code__.co_argcount for _ in ((lambda _: None),(lambda _, __: None),(lambda _, __, ___: None),(lambda _, __, ___, ____: None),(lambda _, __, ___, ____, _____: None),(lambda _, __, ___, ____, _____, ______: None),(lambda _, __, ___, ____, _____, ______, _______: None))])
@halcyon zinc :white_check_mark: Your eval job has completed with return code 0.
hello world
just realized that my goto implementation lets me write loops like this py f = lambda:int(i) if label .start or (i:=input('type a number: ')).isnumeric() else goto .start ```py
n = f()
type a number: no
type a number: 123a
type a number: 123
print(n)
123
type(n)
<class 'int'>
well, interesting to see
honestly i thought it would break my bytecode patcher
well, good if it doesn't
you guys ever heard of unlambda?
r``\``\``\``\``\`.h.e.l.l.o. .w.o.r.l.di
this is the hello world statement without the backspaces
been trying to figure out how to implement this into my python code
!e ```py
from ctypes import c_char
def getmem(addr, size):
return memoryview((c_char*size).from_address(addr)).cast('B')
all = ['goto', 'label']
def getframe(depth=0):
try:raise
except Exception as e:
frame = e.traceback.tb_frame
for _ in range(depth + 1):
frame = frame.f_back
return frame
def get_dest(frame, label):
code, names = frame.f_code.co_code, frame.f_code.co_names
frame_var = {**frame.f_globals, **frame.f_locals}.get
ops, args = code[::2], code[1::2]
for idx, (op, arg) in enumerate(zip(ops, args)):
if op == 106 and names[arg] == label and
isinstance(frame_var(names[args[idx - 1]]), Label):
return (idx - 1) * 2
raise RuntimeError(f'label {label!r} not found')
def set_instr(code, idx, op, arg):
code_addr = id(code) + bytes.basicsize - 1
mem = getmem(code_addr, len(code))
(op, arg), mem[idx:idx + 2] = mem[idx:idx + 2], bytes((op, arg))
return op, arg
restore_instr = [None, None, None]
class Goto:
def getattr(self, label):
code = (frame := getframe(1)).f_code.co_code
idx = frame.f_lasti + 2
op, arg = set_instr(code, idx, 114, get_dest(frame, label))
restore_instr[:3] = (idx, op, arg)
mul = getattr
class Label:
def getattr(self, name):
if None not in restore_instr:
frame = getframe(1)
set_instr(frame.f_code.co_code, *restore_instr)
restore_instr[:3] = (None, None, None)
goto = Goto()
label = Label()
x = 0
label .start
print(x)
if x == 10:
goto .end
x += 1
goto .start
label .end```
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
006 | 5
007 | 6
008 | 7
009 | 8
010 | 9
011 | 10
@sick hound ^ thats how i have goto
very cool
exit()
environments
enumerate
except
@sick hound :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | (_:=lambda _:(_ := _.__add__(__name__.__len__().__bool__().__int__()))
003 | ^
004 | SyntaxError: unexpected EOF while parsing
Hey @robust aspen!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
made a hello world script purely from dunder functions and without numbers https://paste.pythondiscord.com/itogobikap.md
recursive optimization does wonders
3k characters
def f(x):
s={}
for n in x:
if n not in s:s[n]=1
else:
k=s[n]
while(z:=f"{n}({k})")in s:k+=1
s[n]=k+1;s[z]=1
return list(s.keys())
print(f(["doc", "doc", "image", "doc(1)", "doc"]))
``` anyway to shortern this?
hmm, if you use a defaultdict for s, you won't need to set default values to 1 manually
Or you could use k=s.get(n,0). At least, I think that's the function.
No if means less indentation.
Don't think you need the .keys() in list(s.keys()) either```py
x = {'a': 1, 'b': 2, 'c': 3}
list(x.keys())
['a', 'b', 'c']
list(x)
['a', 'b', 'c']```
n+f"({k})"```also saves 1 char
ah yes,
won't 'file(0)' be added then?
if n not in s:s[n]=1
else:
k=s[n]
while(z:=f"{n}({k})")in s:k+=1
s[n]=k+1;s[z]=1``` why not swap the order here to avoid a `not`
so py if n in s: k=s[n] while(z:=f"{n}({k})")in s:k+=1 s[n]=k+1;s[z]=1 else:s[n]=1
[*x] is even shorter
True, forgot about unpacking
Sad
Huh.
Still sad
I am an idiot
r-word 
Fixed
Nice
!e ```py
import inspect
import sys
from importlib.machinery import PathFinder
class LogImporter(PathFinder):
def init(self, print_file_path: bool = False):
self.print_file_path = print_file_path
def find_spec(self, name, path=None, target=None):
print('Importing', name, end=" ", flush=True)
cf = inspect.currentframe().f_back
a = 0
while cf:
a += 1
# Handle non-file frames
if "__file__" not in cf.f_globals:
print("Exec() frame", cf.f_code.co_name, cf.f_code.co_filename)
cf = cf.f_back
continue
# Skip import machinery
if "importlib" in cf.f_globals['__file__']:
cf = cf.f_back
continue
# Print the file path or just the filename
if not self.print_file_path:
print(a, "from file", '/'.join(cf.f_globals['__file__'].rsplit("/")[-2:]))
else:
print(a, "from file", cf.f_globals['__file__'])
break
# clean up our frames explicitly
del cf
# Engage the rest of the import system
return super().find_spec(name, path, target)
sys.meta_path.insert(0, LogImporter())
import json
print(json)
@distant wave :white_check_mark: Your eval job has completed with return code 0.
001 | Importing json Exec() frame <module> <string>
002 | Importing json.decoder 4 from file json/__init__.py
003 | Importing json.scanner 6 from file json/decoder.py
004 | Importing _json 4 from file json/scanner.py
005 | Importing json.encoder 4 from file json/__init__.py
006 | <module 'json' from '/usr/local/lib/python3.9/json/__init__.py'>
!e ```py
print(().class.name.str()[::-(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()))))))))))])
@terse mortar :white_check_mark: Your eval job has completed with return code 0.
tl
replace all the 1s with __debug__
hmm
anyone know an equivalent dunder thingy for 0?
right now im using this
__debug__.__bool__().__str__().__len__().__int__().__sub__(__debug__.__bool__().__str__().__len__().__int__())]
ight
__debug__.__sub__(__debug__)
ik but never hurts to add some length
especially since im making an obfuscator and i need to get rid of any chance of readability
im currently using this for E
!e
print(....__class__().__str__()[__debug__.__bool__().__str__().__len__().__int__().__sub__(__debug__.__bool__().__str__().__len__().__int__())])
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
E
if you're making an obfuscator it should be better for it to be as small as possible
the size doesn't really matter for readability
nvm found what i was looking for
__doc__.__bool__().__int__()
!e
print(
....__class__().__str__()[__doc__.__bool__().__int__()]
)
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
E
much cleaner
if you start Python with -O or -OO, __debug__ will be false
ok
!e __import__("sys").stdout.write(__doc__.__dir__())
@toxic jewel :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: write() argument must be str, not list
none returns 0 correct?
None evaluates to False when needed
!e print(__doc__.__class__().__bool__().__int__())
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
0
pog
I did not really know how to express it anymore ๐
!e
print(
....__class__().__str__()[__doc__.__class__().__bool__().__int__()],
__debug__.__bool__().__str__()[-(__name__.__len__().__bool__().__int__())], sep="\n"
)
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
001 | E
002 | e
perrrrrfect
Another way to say it is that None is falsey.
is __hash__() random?
in cpython yeah
at least it is salted, and the salt changes between interpreter runs
that prevents malicious attacks on the worst case of dict insertion (security issues)
though the salt is always the same inside a Python interpreter's lifetime
wonder how i can get 1 from 0
0 .__invert__().__abs__() do you mean this?
you can do that???
thats crazy
!e
print(....__class__().__hash__().__str__().__len__().__floordiv__(....__class__().__hash__().__str__().__len__()))
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
1
tryna make a list of integers
!e
(
zero := (__doc__.__bool__().__int__()),
one := (__doc__.__bool__().__int__()).__invert__().__abs__(),
two := (__name__.__len__().__bool__().__int__().__add__(__name__.__len__().__bool__().__int__())),
three := (__debug__.__str__().__len__().__sub__(__debug__.__int__()))
)
print(zero, one, two, three)
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
0 1 2 3
heres what i have so far
any tips
trying not to use any of the same techniques in any
for 4 you can do {}.__class__.__name__.__len__()
for 5 you can do (__name__,).__class__.__name__.__len__()
four = ....__class__.__name__.__len__().__rshift__(....__class__.__base__().__sizeof__().__bool__())
six = ().__class__.__base__.__name__.__len__()
for 4 I got [[]].__str__().__len__()
and just removing and adding the brackets as needed
Isn't that only for strings and bytes?
!e
(__builtins__.__dict__['globals']().__setitem__('__',[].__len__()),__builtins__.__dict__['globals']().__setitem__('___',__debug__.__int__()),__builtins__.__dict__['list'](__builtins__.__dict__['map'](lambda _:[(__builtins__.__dict__['print'](__),__builtins__.__dict__['globals']().__setitem__('____',__.__add__(___)),__builtins__.__dict__['globals']().__setitem__('__', ___),__builtins__.__dict__['globals']().__setitem__('___',____))], [__]*__name__.__len__().__lshift__(__debug__))))
@robust aspen :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
003 | 1
004 | 2
005 | 3
006 | 5
007 | 8
008 | 13
009 | 21
010 | 34
011 | 55
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/oyibuwolat.txt
that was fun
!e
print({}.__class__.__name__)
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
dict
very smart
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
str
!e
print(''.__str__().__class__.__name__)
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
str
!e ```py
class Aaaaaa(float):
def init(self,value):self.value=value;self.dec=0;super().init()
def getattr(self,attr):
if attr in dir(float()):return super().getattr(attr)
elif attr=='point':self.dec=1 if not self.dec else self.dec
elif self.dec:self.dec+=1;return self+{"one":1,"two":2,"three":3,"four":4,"five":5,"six":6,"seven":7,"eight":8,"nine":9,"zero":0}[attr]*(10**(-self.dec+1))
return self
four_hundred_and_twenty=Aaaaaa(420)
print(four_hundred_and_twenty.point.seven.eight)
From memory you can also edit the actual exit object's attributes, unlike many other Python things.
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 9, in <module>
003 | AttributeError: 'float' object has no attribute 'eight'
@floral meteor what do you mean
the Aaaaaa class getattr method holds until four_hundred_and_twenty.point.seven.eight is attempted, at which point it claims that the float object has no attribute eight even though i explicitly told it how to handle attribute not found error
>>> a=Aaaaaa(420)
>>> type(a.point)
<class '__main__.Aaaaaa'>
>>> type(a.point.seven)
<class 'float'>
>>> ```
class Aaaaaa(float):
def __init__(self,value,dec=0):self.value=value;self.dec=dec;super().__init__()
def __getattr__(self,attr):
if attr in dir(float()):return super().__getattr__(attr)
elif attr=='point':self.dec=1 if not self.dec else self.dec
elif self.dec:return Aaaaaa(self+{"one":1,"two":2,"three":3,"four":4,"five":5,"six":6,"seven":7,"eight":8,"nine":9,"zero":0}[attr]*(10**(-self.dec+1)),dec=self.dec+1)
return self
four_hundred_and_twenty=Aaaaaa(420)
print(four_hundred_and_twenty.point.seven.eight.six.six)
!e ```py
class Aaaaaa(float):
def init(self,value,dec=0):self.value=value;self.dec=dec;super().init()
def getattr(self,attr):
if attr in dir(float()):return super().getattr(attr)
elif attr=='point':self.dec=1 if not self.dec else self.dec
elif self.dec:return Aaaaaa(self+{"one":1,"two":2,"three":3,"four":4,"five":5,"six":6,"seven":7,"eight":8,"nine":9,"zero":0}[attr]*(10**(-self.dec+1)),dec=self.dec+1)
return self
four_hundred_and_twenty=Aaaaaa(420)
print(four_hundred_and_twenty.point.seven.eight.six.six)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
427.866
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
!e ```py
class Aaaaaa(float):
def init(self,value,dec=0):self.value=value;self.dec=dec;super().init()
def getattr(self,attr):
if attr in dir(float()):return super().getattr(attr)
elif attr=='point':self.dec=1 if not self.dec else self.dec
elif self.dec:return Aaaaaa(self+{"one":1,"two":2,"three":3,"four":4,"five":5,"six":6,"seven":7,"eight":8,"nine":9,"zero":0}[attr]*(10**(-self.dec)),dec=self.dec+1)
return self
four_hundred_and_twenty=Aaaaaa(420)
print(four_hundred_and_twenty.point.seven.eight.six.six)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
420.78659999999996
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
aha
!e ```py
class Aaaaaa(float):
def init(self,value,dec=0):self.value=value;self.dec=dec;super().init()
def getattr(self,attr):
if attr in dir(float()):return super().getattr(attr)
elif attr=='point':self.dec=1 if not self.dec else self.dec
elif self.dec:return Aaaaaa(round(self+{"one":1,"two":2,"three":3,"four":4,"five":5,"six":6,"seven":7,"eight":8,"nine":9,"zero":0}[attr]*(10**(-self.dec)),self.dec+1),dec=self.dec+1)
return self
four_hundred_and_twenty=Aaaaaa(420)
print(four_hundred_and_twenty.point.seven.eight.six.six)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
420.7866
ahahahahahahahahahahahahahahahahahahahahaha i am invincible
alright i need to reverse engineer my own cipher to get the key given a token and the encrypted token.
I have...
def enigma_de(source:str,key:str):
"""algorithm to decrypt substitution cipher.
e.g. t,F => N
"""
if len(source)<len(key):key=key[:len(source)] # wrap key to match source size
elif len(source)>len(key):key=(key*(len(source)//len(key)+1))[:len(source)]
_s=[ord(c)for c in list(source)];_k=[ord(c)for c in list(key)];_p=[] # init
for i,e in enumerate(_s):_p.append((((e-32)-(_k[i]-32))%95)+32) # <-- decryption algorithm
return''.join([chr(n)for n in _p]) # return token
def enigma_en(source:str,key:str):
"""algorithm to encrypt substitution cipher.
e.g. N+F => t
"""
if len(source)<len(key):key=key[:len(source)] # wrap key without requiring itertools
elif len(source)>len(key):key=(key*(len(source)//len(key)+1))[:len(source)]
_s=[ord(c)for c in list(source)];_k=[ord(c)for c in list(key)];_p=[] # encode (_s,_k) and initialise variables (_s,_k,_p)
for i,e in enumerate(_s):_p.append((((e-32)+(_k[i]-32))%95)+32) # encrypt raw data
return''.join([chr(n)for n in _p]) # decode _p and return it****
given that's the cipher, how would I, after evaluating...
>>> secret = "shh this is a secret"
>>> gobbledygook = enigma_en(secret,"P455w0rd1")
... get "P455w0rd1" from some function of secret and gobbledygook ?
but don't tell me the straight answer
I just need help thonking of me own answer
if no one says anything i'm kinda just gonna keep rambling until i figure it out on me own
:P
!e ```py
{print(int("9"*20)**int("9"*20))for _ in iter(int,1)}
@floral meteor :warning: Your eval job timed out or ran out of memory.
[No output]
aw that all
i got... ```nim
File "<string>", line 1, in <module>
KeyboardInterrupt
Exception in thread Thread-2:
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedWriter name='<stderr>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=000002D8773C38B0)
Current thread 0x000042fc (most recent call first):
<no Python frame>
B:>
you can't really evaluate keyboard interrupting that i guess
what was the code that caused that error?
i would assume
what does .__rshift__() do?
support the >> operator
ah
!e
print({}.__class__().__hash__().__int__().__rshift__(__debug__.__add__(__debug__.__mul__(__debug__.__add__(__debug__)))))
@toxic jewel :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: 'NoneType' object is not callable
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
4578586700643154856
oh
dicts are not hashable
converting the word dict to a str to hash it
trollar
recreating random.randint but it only works from 50-60 something and its almost always 63
!e
print({}.__class__().__str__().__hash__().bit_length())
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
63
!e print({}.__class__().__str__().__hash__().__dir__())
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
['__repr__', '__hash__', '__getattribute__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__add__', '__radd__', '__sub__', '__rsub__', '__mul__', '__rmul__', '__mod__', '__rmod__', '__divmod__', '__rdivmod__', '__pow__', '__rpow__', '__neg__', '__pos__', '__abs__', '__bool__', '__invert__', '__lshift__', '__rlshift__', '__rshift__', '__rrshift__', '__and__', '__rand__', '__xor__', '__rxor__', '__or__', '__ror__', '__int__', '__float__', '__floordiv__', '__rfloordiv__', '__truediv__', '__rtruediv__', '__index__', '__new__', 'conjugate', 'bit_length', 'to_bytes', 'from_bytes', 'as_integer_ratio', '__trunc__', '__floor__', '__ceil__', '__round__', '__getnewargs__', '__format__', '__sizeof__', 'real', 'imag', 'numerator', 'denominator', '__doc__', '__str__', '__setattr__', '__delattr__', '__init__', '__reduce_ex__', '__reduce__', '__subclasshook__', '__init_subclass__', '__dir__', '__class__']
what
!e
print({}.__class__().__str__().__hash__().__rshift__(__debug__.__int__().__hash__()))
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
1631837941395044143
i love myself some random seeds
whats that
long number
!e
[print({}.__class__().__str__().__hash__().__rshift__(__debug__.__int__().__hash__()))for(x)in(range(__debug__.__int__().__hash__()))]
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
310679553258299720
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
1
oh
^ is xor
!e
[print({}.__class__().__str__().__hash__().__rshift__(__debug__.__int__().__hash__()))for(x)in(range(__debug__.__int__().__hash__().__rshift__(().__class__().__str__().__hash__().strip("-"))))]
@toxic jewel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | AttributeError: 'int' object has no attribute 'strip'
How to add an economy work command?
users = await get_bank_data()
^
IndentationError: expected an indented bloc
# LEADERBOARD
@client.command(aliases = ["lb"])
async def leaderboard(ctx,x = 1):
users = await get_bank_data()
leaderboard = []
for user in users:
leaderboard += (int(user), users[user]["wallet"] + users[user]["bank"])
leaderboard = sorted(leaderboard, key=lambda a: a[1])
# embed stuff here
for index, user in enumerate(leaderboard):
em.add_field(
name=client.get_user(int(user[0])),
value=f"{index}: {user[1]}"
)
await ctx.send(embed = em)
How can i fix that?
your in the wrong channel for that
!e
chr(__name__.__len__().__mul__(__name__.__len__().__add__(__debug__))).__add__(chr(__name__.__len__().__add__([].__str__().__len__()).__pow__([].__str__().__len__()).__add__(__debug__))).__add__(chr(__name__.__len__().__add__(__debug__).__mul__([[[]]].__str__().__len__().__lshift__(__debug__))).__mul__([].__str__().__len__())).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__add__(__name__.__len__())).__sub__(__debug__))).__add__(chr([[]].__str__().__len__().__mul__(__name__.__len__()))).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__lshift__(__debug__).__sub__(__debug__)).__sub__(__debug__))).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__add__(__name__.__len__())).__sub__(__debug__))).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__add__(__name__.__len__())).__add__([].__str__().__len__()))).__add__(chr(__name__.__len__().__add__(__debug__).__mul__([[[]]].__str__().__len__().__lshift__(__debug__)))).__add__(chr(__name__.__len__().__add__([].__str__().__len__()).__pow__([].__str__().__len__()))).__add__(chr([[]].__str__().__len__().__mul__(__name__.__len__()).__add__(__debug__)))
@robust aspen :warning: Your eval job has completed with return code 0.
[No output]
!e
print(chr(__name__.__len__().__mul__(__name__.__len__().__add__(__debug__))).__add__(chr(__name__.__len__().__add__([].__str__().__len__()).__pow__([].__str__().__len__()).__add__(__debug__))).__add__(chr(__name__.__len__().__add__(__debug__).__mul__([[[]]].__str__().__len__().__lshift__(__debug__))).__mul__([].__str__().__len__())).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__add__(__name__.__len__())).__sub__(__debug__))).__add__(chr([[]].__str__().__len__().__mul__(__name__.__len__()))).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__lshift__(__debug__).__sub__(__debug__)).__sub__(__debug__))).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__add__(__name__.__len__())).__sub__(__debug__))).__add__(chr(__name__.__len__().__mul__([[[]]].__str__().__len__().__add__(__name__.__len__())).__add__([].__str__().__len__()))).__add__(chr(__name__.__len__().__add__(__debug__).__mul__([[[]]].__str__().__len__().__lshift__(__debug__)))).__add__(chr(__name__.__len__().__add__([].__str__().__len__()).__pow__([].__str__().__len__()))).__add__(chr([[]].__str__().__len__().__mul__(__name__.__len__()).__add__(__debug__))))
@robust aspen :white_check_mark: Your eval job has completed with return code 0.
Hello World!
yea just the shortest equations I could get for each value
takes about 30s to generate
working on numbers only using dunders
zero = (__doc__.__bool__().__int__())
one = (zero.__invert__().__abs__())
two = ({}.__class__().__str__().__len__())
three = (''.__class__.__name__.__len__())
four = ({}.__class__.__name__.__len__())
five = (().__class__.__name__.__len__())
not sure what to use for 6
think im gonna use complex for 7
you could do zero = {}.__len__(), or something like that
ยฏ_(ใ)_/ยฏ
for one I just use __debug__
__debug__ can be false if you use -O
not perfect but works
i think the next smallest one is __name__.__len__().__bool__()
you could also do all even with [].__str__().__len__() with more brackets but thats a bit boring
or
True
One of my personal favorites is (__import__("__future__").__doc__.__str__().__len__().__int__().__bool__())
which returns true, but future kinda changes alot of things so !e cant handle it
ooh ive just came across a new 0 and 1
!e
_0 = (__import__("__main__").__doc__.__bool__().__int__())
_1 = (__import__("__main__").__doc__.__str__().__len__().__bool__().__int__())
print(_0, _1)
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
0 1
even longer strings to add into my number-inator
great
!e
print(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__add__(_:=(__import__("__main__").__doc__.__str__().__len__().__bool__().__int__()).__int__()))))))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
10
heres the src now
import sys
with open("writeoff.txt", "w") as f:
temp=int(sys.argv[1])-2
f.write("print(_:=(__import__(\"__main__\").__doc__.__str__().__len__().__bool__().__int__()).__add__(")
for i in range(temp):
f.write("_:=(__import__(\"__main__\").__doc__.__str__().__len__().__bool__().__int__()).__add__(")
f.write("_:=(__import__(\"__main__\").__doc__.__str__().__len__().__bool__().__int__()).__int__()" + ")" * int(temp+2))
hello, can someone help me figure out what the source code is ?
Yes I can, it's right here #esoteric-python message
thank you.
lmao
what in gods name
That is honest to god programming!
is there a way to redefine True to be False using ctypes? my interpreter exits when I try to access the value
fib = lambda x: (__doc__.__bool__().__int__()) if x < (__doc__.__bool__().__int__().__invert__().__abs__()) else (__doc__.__bool__().__int__().__invert__().__abs__()) if x == (__doc__.__bool__().__int__().__invert__().__abs__()) else fib(x - (__doc__.__bool__().__int__().__invert__().__abs__())) + fib(x - (__doc__.__bool__().__int__().__invert__().__abs__()) - (__doc__.__bool__().__int__().__invert__().__abs__()))
check my fibonacci function
What's the point of inverting something just to get its absolute value?
not sure if this is really python but heres my own esoteric lang print that was made in python
\>>|{<---><<~--<>..>>]][[]].,/'|'}msg?=()l.trollared <<.compr..meth!!!!>>< >>/<<>+.__add*(int:msg.compile,$.radd::std::cout<<'trollared';int::main;def::main::(return(fstr.//'msg.{m3th.m3th.m3th,<i.love<boys>>}',endl.=[]))*((.) <$_<<++-#<<->return()if(not)__debug__.__bool__())][;cout<<::msg?|=f&>**(*,**,func?=m41n(##>:)
you can get 0 from 1
!e ```py
print([1,2,3,4,5].len().abs())
print([1,2,3,4,5].len().invert().abs())
yeah
@terse mortar :white_check_mark: Your eval job has completed with return code 0.
001 | 5
002 | 6
What the fuck
invert 1 is -2
!e
print((__doc__.__bool__().__int__()).__invert__().__abs__())
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
1
there's no point in doing __int__ on a bool
thats not true
And how is that not true?
0/1 is different to False/True
print((__doc__.__bool__()).__invert__().__abs__()) the code should be this
yes.. I know
I am well aware
its esoteric python there is no practical use for any of this
the more complex it looks the better
How does __int__() make it look more complex?
its more characters
that's worse
thats subjective
the longer your esoteric code generator is, the worse it is imo
It's always the best for your esoteric code generator to generate the smallest code as possible
unnecessary things that add more space just make it worse
ik just adds length
with my esoteric code generator you feed a string in thats == 1 and it generates an equation based off of it
Wtf have I stumbled into
what in the world is this channel
Everything you wouldn't put in production code.
I accept your challenge
time for ultimate job security
I want an obfuscator that only changes Python's readability to about the level of C.
you can prolly do this by using semicolons instead of linebreaks
!e ```py
time=....class.class("Now",(),{'iter':(lambda s:s),'next':(lambda s:import('time').time()),'call':(lambda s:s.next())})()
print(time())
for i in time: print(i)
@floral meteor :x: Your eval job timed out or ran out of memory.
001 | 1612669962.330515
002 | 1612669962.3306365
003 | 1612669962.3306687
004 | 1612669962.3306978
005 | 1612669962.3307257
006 | 1612669962.3307536
007 | 1612669962.330781
008 | 1612669962.3308082
009 | 1612669962.3308358
010 | 1612669962.3309991
011 | 1612669962.331042
... (truncated - too many lines)
Full output: too long to upload
U like?
!e
import time
def random():
return (time.time()**2)%1.0
print(*[random() for i in range(10)])
@hard spoke :white_check_mark: Your eval job has completed with return code 0.
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
!e
import time
def random():
return (float(time.time())**2)%1.0
print(*[random() for i in range(10)])
nah, I'm fairly sure it gives non-ints when float%float
Try string, then chop it in half, then the right half is pretty much random
!e
import time
def random():
return time.time() % 1.0
print(*[random() for i in range(10)])
@hard spoke :white_check_mark: Your eval job has completed with return code 0.
0.873577356338501 0.8735852241516113 0.8735859394073486 0.8735864162445068 0.873586893081665 0.8735873699188232 0.8735880851745605 0.8735885620117188 0.873589038848877 0.8735895156860352
to make it float, float("0."+yay)
why does it start being zero after I square it?...
!e
import time
print(time.time(),time.time()**2)
print(time.time()%1,time.time()**2 % 1)
@hard spoke :white_check_mark: Your eval job has completed with return code 0.
001 | 1612670327.4599767 2.60070558506987e+18
002 | 0.46011853218078613 0.0
weeeird
must be a float problem
too large a number => not enough precision to reach that decimal place
!e
import time
def random():
return (time.time()%100000)**2%1.0
print(*[random() for i in range(10)])
@hard spoke :white_check_mark: Your eval job has completed with return code 0.
0.3099184036254883 0.49164390563964844 0.6930341720581055 0.7937288284301758 0.8944234848022461 0.02868366241455078 0.09581375122070312 0.2300739288330078 0.3307685852050781 0.43146419525146484
yeah, that was it
I see a pattern. Try range 50 you'll see pattern.
Oh me thinks of great idea ahahaha
of course there's a pattern, it's #esoteric-python, it wasn't meant to be an actual random number generator ๐
!e ```py
class Wait:
time=import('time').time
def init(s,t=1):s._wait=t;s.now=0
def iter(s):s.now=s.time();return s
def next(s):
t=s.time();
if t<s.now+s._wait: return t-s.now
else: raise StopIteration
a=[now for now in Wait(0.1)]
print(len(a))
Oh r00d
Aha
Wait
Ouch
Wow
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
168916
this channel's great and this is totally perfect code style
idk what ppl are concerned bout /s
!e
l = [[[["Hello, world!",4],3],2],1]
print(l[0][0][0][0])
@lone scarab :white_check_mark: Your eval job has completed with return code 0.
Hello, world!
!e
t = (((("Hello World!",),),),)
print(t[0][0][0][0])
@cloud fossil :white_check_mark: Your eval job has completed with return code 0.
Hello World!
!e
t = (((("Hello World!",),),),)
print(t[False][False][False][False])
@cloud fossil :white_check_mark: Your eval job has completed with return code 0.
Hello World!
!e
t = (((("Hello World!",),),),)
print(t[None][False][False][False])
@cloud fossil :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: tuple indices must be integers or slices, not NoneType
yo i didn't know bool is actually a subclass of int
!e
print(int(True))
print(int(False))
@full jewel :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 0
Default value of False is 0 and True is 1
Not exactly a default value, they are just ones and zeros that look a little different. In a previous Python, integers were used for the (at he time unimplemented) Booleans, and it's a holdover from maintaining backwards compatibility with that.
issubclass(bool, int) returns True
Well yes, it says in the python docs that bool is a subclass of int
@umbral latch :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print (1===1)
003 | ^
004 | SyntaxError: invalid syntax
This isn't JavaScript ๐
I can see how you would get that confused with this channel tho
๐
!e 1==(_:=1)
@sick hound :warning: Your eval job has completed with return code 0.
[No output]
!e print(1==(_:=1))
@verbal totem :white_check_mark: Your eval job has completed with return code 0.
True
!e print(f"{a=}")
@last locust :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 'a' is not defined
!e lambda x: print(f"{x=}")(3)
@last locust :warning: Your eval job has completed with return code 0.
[No output]
!e py l = lambda x: print(x) l(3)
@last locust :white_check_mark: Your eval job has completed with return code 0.
3
!e py lambda x: print(x)(3)
@last locust :warning: Your eval job has completed with return code 0.
[No output]
@last locust :white_check_mark: Your eval job has completed with return code 0.
3
!e py (lambda x: print(f"{x=}"))(3)
@last locust :white_check_mark: Your eval job has completed with return code 0.
x=3
ok so why does ```py
print([].len().bool().str().len().add([1].len().bool().str().len()).str().add([].len().bool().str().len().add([1].len().bool().str().len()).str()).int())
```py
print(int([].__len__().__bool__().__str__().__len__().__add__([1].__len__().__bool__().__str__().__len__()).__str__().__add__([].__len__().__bool__().__str__().__len__().__add__([1].__len__().__bool__().__str__().__len__()).__str__())))
int(str) does not call str.__int__(), the parsing is in the int constructor
I did not know that, thanks.
@floral meteor yo your Cursed(float) breaks on this
ik its very broken
!e import antigravity
@low apex :warning: Your eval job has completed with return code 0.
[No output]
of course
kids learn ur times table
This isn't what this channel is for
it's for the ppl who uses python like this
!e
print(....__class__().__str__()[__debug__.__bool__().__str__().__len__().__int__().__sub__(__debug__.__bool__().__str__().__len__().__int__())])
@fluid prawn :white_check_mark: Your eval job has completed with return code 0.
E
Hey, I can actually follow this snippet haha
i can
print(str(type(...)())[ len(str(bool(__debug__))) - len(str(bool(__debug__))) ])
print(str(Ellipsis)[len(str(True))-len(str(True))])
print("Ellipsis"[len("True")-len("True")])
print("Ellipsis"[4-4])
print("Ellipsis"[0])
print("E")
That's similar to this ```py
print(().class.name.str()[::-(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()))))))))))])
maybe
!e print(().class.name.str()[::-(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()).sub(().class.name.str().len().sub([1].len().bool().str().len()))))))))))])
@cloud fossil :white_check_mark: Your eval job has completed with return code 0.
tl
Does it support an optional -and-
after a few hours, ive finally finished it. 10k char hello world program!
onliner: https://gist.github.com/ChiliMX/cc81819f8ffc13387d8d2dc9cebdaef0
pycharm reformat: https://gist.github.com/ChiliMX/821bf6db53a5b6104bfcb516e2c5bd83
Pycharm code reformat made my amazing oneliner(check out my other gist) into this - no longer a one liner.py
wow
what's next? 100k?
well, replaceing sqrt into dunders in that program
i did it with math so its def possible.
well, x**.5 is close (but not equal in all circumstances) to sqrt(x)
so x.__pow__((1).__truediv__(2)) could work (however you define 1 and 2)
Yeah ik. I mean like writing out the letters sqrt just in dunders
Depends on what x is
If it is a Decimal object, then it will be the same
yeah, that's why floating point maths is annoying
I think y'all are misunderstanding me. I'm going to make the word sqrt using chr and Dunders
oh, right
Haha nice
That's what I did with the word math(variable ______ in this case), and it works AND it adds like 1k chars
Hey @terse mortar!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
I did not mean to do that.
very cool
reminds me of my hello world statement
editing ascii values i assume?
i love how wavy it is
Na, it's actually just doing eval("__import__('__hello__')") with chr
ah very cool
ty ty
why not __str__() or __len__() or ... for ellipsis
i merely translated the dunder methods to built-in functions
yikes naming variables uwu
then just name it __
keep stacking the underscores lol
ok lets make sqrt with just dunders
"assignment expression cant be used in list comprehension"
life ruined
so glad i have a program to make these long strings
muahahahahaha
nooooooooooooooooooooooo
make your own esoteric language using Python
LMFAOOOO MY COMPSCI TEACHER DOESNT THINK ITS REAL PYTHON LOL
If i knew how to I would
there's a lot of tutorials online
I think how it goes is you have to build a lexer and then make your own syntax
here's an idea: make a programming language with only words
as in py print("Hello, World!") would be print OPENING_BRACKET DOUBLE_QUOTE UPPER_LETTER H LETTER E LETTER L LETTER L LETTER O COMMA UPPER_LETTER W LETTER O LETTER R LETTER L LETTER D DOUBLE_QUOTE CLOSING_BRACKET
something like that lol
Lol I mean I'm sure it's possible
Just like use ascii chars, since they are in uppercase, right?
I think it'd require regex
I really wanna make my own little fun language with python
If you make a github project I'll contribute
heres a fun way i found to print 66
!e
print((....__class__().__str__().__hash__().__abs__().as_integer_ratio.__str__().__len__()))
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
66
why not
$(LETTER P LETTER R LETTER I LETTER N LETTER T) OPENING_BRACKET DOUBLE_QUOTE UPPER_LETTER H LETTER E LETTER L LETTER L LETTER O COMMA UPPER_LETTER W LETTER O LETTER R LETTER L LETTER D DOUBLE_QUOTE CLOSING_BRACKET
how tf did you get the green highlight?
```tex
$highlight$
```
it has to have the $ dollar sign in front of it to be highlighted
yes
LaTeX is TeX plus some extra macros.
A lot of convenience macros
!e
print(int(str((1 << (1 << (1 << 1))) * ((11 << 1) + 1)), 1 << (1 << (1 << 1))))
A shortest expression I can do that getting 872 only using the digit 1.
@summer tulip :white_check_mark: Your eval job has completed with return code 0.
872
!e
print((((((((True << (((True << True) + True))) - True) << (True << True))) - True) << (True << True)) + True) << ((True << True) + True))
This time without integer literals and multiplication which is more computing-expensive than bit-shifts.
@summer tulip :white_check_mark: Your eval job has completed with return code 0.
872
!e
import timeit
print(timeit.timeit('(((((((True << (((True << True) + True))) - True) << (True << True))) - True) << (True << True)) + True) << ((True << True) + True)', number=5000000))
print(timeit.timeit('872', number=5000000))
Apparently the esoteric expression is sometimes faster than the literal. ๐
@summer tulip :white_check_mark: Your eval job has completed with return code 0.
001 | 0.058903101831674576
002 | 0.0643576211296022
!e
import timeit
print(timeit.timeit('(((((((True << (((True << True) + True))) - True) << (True << True))) - True) << (True << True)) + True) << ((True << True) + True)', number=5000000))
print(timeit.timeit('872', number=5000000))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 0.08057978143915534
002 | 0.06087453104555607
!e
import timeit
print(timeit.timeit('(((((((True << (((True << True) + True))) - True) << (True << True))) - True) << (True << True)) + True) << ((True << True) + True)', number=50000000))
print(timeit.timeit('872', number=50000000))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 0.6325192009098828
002 | 0.7232883931137621
pretty sure that's just a measurement error
each operation would take nanoseconds on its own
$highlight be cool$
!e py import dis dis.dis('(((((((True << (((True << True) + True))) - True) << (True << True))) - True) << (True << True)) + True) << ((True << True) + True)')
@stark fable :white_check_mark: Your eval job has completed with return code 0.
001 | 1 0 LOAD_CONST 0 (872)
002 | 2 RETURN_VALUE
lmfao
