#esoteric-python
1 messages Β· Page 101 of 1
that's negative self-talk
why would you be meaner to yourself than you would be to other people?
Because I struggle with self confidence π
dunno if it'll work for you, works for me on 3.8.2: https://paste.pythondiscord.com/igawikevic.py
I mean there's something to be said for being aware of where you can improve and just being grounded in reality in general, but a lot of the time people compare their deepest insecurities to other people's most polished presentation.
and that's, like, the exact opposite of what makes sense.
if your self confidence is bad you should work on improving it instead of saying things that make it even worse π€¨
Right, but like, it's not that easy. Plus I'm so fucked up anyways lol, that my self confidence isn't rly a big problem. If you want to get more into it, y'all can dm me, but we probably shouldn't do this here.
def all_numbers():
n = 0
while True:
n += 1
yield n
how could I make this function in one line?
def all_numbers():
n = 0
while True: yield (n := n + 1)
walrus can do that
all_numbers = lambda n=0: (n := n + 1, (yield n), (yield from all_numbers(n))
Eventually you will die of recursion error
!e
all_numbers = (lambda n=0: (n := n + 1, (yield n), (yield from all_numbers(n)))
all_numbers()
@fiery hare :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | all_numbers()
003 | ^
004 | SyntaxError: invalid syntax
I wonder if you could reallocate the call stack with ctypes or something something... probably not but would be interesting
missing a closing bracket at the end there
!e
all_numbers = (lambda n=0: (n := n + 1, (yield n), (yield from all_numbers(n))))
all_numbers(10)
@fiery hare :warning: Your eval job has completed with return code 0.
[No output]
!e
print("hello")
@zinc patio :white_check_mark: Your eval job has completed with return code 0.
hello
YOOO THAT'S SO COOL
If anyone know if I cna get the source code of this bof
Bot
Cuz I kinda wanna try to hack it
Run Python code and get the results.
You won't be able to lol. There have been hundreds of thousands, maybe millions of attempts to break the bot, but so far only three people have managed. So uhh yeah gl.
Sure, but staff recommend if you want to try to make it ping someone, just make it ping yourself.
!e
while True:
print("the")
@sick hound :x: Your eval job timed out or ran out of memory.
001 | the
002 | the
003 | the
004 | the
005 | the
006 | the
007 | the
008 | the
009 | the
010 | the
011 | the
... (truncated - too many lines)
Full output: too long to upload
#bot-commands for testing please @sick hound
ight
all_numbers = __import__('itertools').count``` π
idk if there's a way to do it "properly" without using itertools like that
alright actually this works py all_numbers = type('',(),{'__init__':lambda a:a.__setattr__('i',0),'__iter__':lambda a:a,'__next__':lambda a:a.__setattr__('i',a.i+1)or a.i})
it's not strictly a function anymore but you can call it and it will behave like the function did
@cloud garden
I would do
all_numbers = lambda: iter(lambda n=[-1]: next(n[0] for n[0] in [n[0]+1]), None)
I remember there being a golf about this a while back
!e py all_nums=iter(lambda n={0:0}:[n[0],n.update({0:n[0]+1})][0],-1) for i in range(20):print(next(all_nums))
@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
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/yarilateqa.txt
oh yeah i forgot about iter
Write terribly illegible, working code
Usually all done on one line @cani#6647
or modifying Python's base behaviour on the fly
Reinventing the wheel is #esoteric-python too
definitely. If it's totally weird, it probably belongs here
I swear I saw this somewhere, proving that people need to put more effort in finding the right people for the right job:
if False == False:
return True
bruh
yield False==False and True or False
class Maybe:
def _rat_mat(s,n):
b=c=1
while not-2**-10<n-int(n)<2**-10:c+=1;n*=c;b*=c
return[*[True]*int(n),*[False]*int(b)]
def __init__(s,n:float=1.0):s.l=__import__('math').log;s.c=n>0 and s._rat_mat(n)or(n<0 and s._rat_mat(-1/n))or True;s.r=__import__('random')
__bool__=lambda s:s.r.choice(s.c)
wat
!e ```py
def _rat_mat(n):
a,b,c=n,1,1
while not-2**-10<a-int(a)<2**-10:c+=1;a*=c;b*=c
return[*[True]int(a),[False]*int(b)]
{print(rat_mat())for _ in[0.1,1.4,2.4,0.00343581,0.5158,26.2,98765.000002]}
@floral meteor :x: Your eval job has completed with return code 1.
001 | [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]
002 | Traceback (most recent call last):
003 | File "<string>", line 5, in <mod
... (truncated - too long)
Full output: https://paste.pythondiscord.com/enikehocaw.txt
there
MemoryError
```LMAO
me: evaluate simple algorithm
bot's last two brain cells: monke think
how do I get the numerator and denominator of a float separated?
into a tuple
something like...
def _frac_float(n):
if-2**-10<n-int(n)<2**-10:return n,1
else:...
def _rat_mat(n):a,b=_frac_float(n);return[*[True]*a,*[False]*b]
without importing math
or is there a thing I could do to go through 128 iterations and do something to n, and if certain conditions apply to n, assign True, else False, then return the thingy...
π€

oof
the bot hates me now
bruh
okay I think this is an algorithm issue not an esoteric topic. I'll make it non-esoteric-coder friendly
ow it hurts my eyes already :P
!e py x = 1.2 print(x.__trunc__()) print(x.__ceil__())
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
@floral meteor ^ i think that works
i'd expect that output for 0.5
!e
rn I'm trying to get at least this to work, I'll try this
def _rat_mat(n):
n = (n<0) and -n or +n
if -10**-10 < n-int(n) < 10**-10:f = [*[True]*int(n), False]
else:
f=[]
for i in range(128):
if n>1: f.append(True);n-=1/(i+1)
else: f.append(False);n+=1/(i+1)
return f
print({this:_rat_mat(this)for this in [0.1,0.2,0.5,1.2,5,0.3]})
well that does something
!e ```py
def _rat_mat(n):
n = (n<0) and -n or +n
if -10**-10 < n-int(n) < 10**-10:f = [*[True]*int(n), False]
else:
f=[]
for i in range(128):
if n>1: f.append(True);n-=1/(i+1)
else: f.append(False);n+=1/(i+1)
return f
def _frac(m):
a=b=0
for this in m:
if this:a+=1
else:b+=1
return f"{a}/{b}"
print({this:_frac(_rat_mat(this))for this in [0.1,0.2,0.5,1.2,5,0.3]})
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
{0.1: '63/65', 0.2: '63/65', 0.5: '64/64', 1.2: '63/65', 5: '5/1', 0.3: '64/64'}
when you run eval it evaluates your code against something? asking for a friend @floral meteor lol
si'?
wdym?
when you run eval it evaluates the string as python and returns the value the evaluation returned.
like in prompt when you enter a string into stdin followed by a newline, it evalautes that and prints the value
so eval is like that but it returns string instead of printing it
and it inputs string instead of raw code
alright...
!e ```py
class Maybe:
def _rat_mat(s,n):
r = n.as_integer_ratio()
_={(r:=(int(r[0]/100000),int(r[1]/100000)))for _ in iter(lambda:r[0]>1000 and r[1]>1000, False)}
a,b=r
return[*[True]a,[False]*b]
def init(s,n:float=1.0):s.l=import('math').log;s.c=n>0 and s._rat_mat(n)or(n<0 and s._rat_mat(-1/n))or True;s.r=import('random')
bool=lambda s:s.r.choice(s.c)
{Maybe(0.2) and print("Low Battery") for _ in range(50)}
the string as in the string typed into discord message?
bot ded lol
eh, I was talking about python shell
if you did eval on a discord message, people would hack ur bot
running code in discord is actually a complicated process...
essentially, you don't want print to actually print to stdout, but to a file, which you then read.
or set sys.stdout to a file handle
which you then read and wipe when you read
and you also gotta filter out harmful commands
it's a lot of stuff to do
okay so the bot is interpreting your code? in a way?
in my bot I just did
if message.author.id in FRIENDLY_IDS and message.content.translate(str.maketrans('','',string.punctuation)).lower().startswith(
'python'):global msg;msg=await send(message.channel,str(process_python_command(message)))
```
instead of filtering
does this alert you when friendly people msg you
no, when a friendly person requests to evaluate some code, it passes the code to process_python_command then sends the output back to them
the function itself is an eyesore, and not actually finished.
def process_python_command(m):
c=m.content[len(m.content.split()[0])+1:]
try:return eval(c,__locals=globals())
except Exception as e:
b=globals().copy()
try:exec(c,globals(),globals());return"Executed with exit code `0`."+(globals()!=b)*(" Changed variables:\n"+str({this:globals()[this]for this in globals() if this not in b or b['this']!=globals()['this']}))+((f:=open(_STDOUT,'r')).read()and[f.seek(0),f.read(),f.close(),open(_STDOUT,'w').close()][1])
except Exception as _e:return"Executed with exit code `1`."+str({'eval':str(e),'exec':str(_e)})
since you asked in the esoteric-python channel, you get to look at ugly code like this
that's what i'm here for i assure you
you and I are two of the few people brave enough to combine esoteric python with discord.py
hol up
didn't even get a chance to read it all lol
it copied a different section to what i highlighted lol
doxx
# redirects
log=lambda *s,sep=' ',end='\n':os.system("")or sys.__stdout__.write(sep.join(s)+end)
print=lambda *s,sep=' ',end='\n',file=_STDOUT:[(f:=(open(file or _STDOUT,'a'+'b'*isinstance(s,bytes))if isinstance(file,str)else file)).write(sep.join(s)+end),f.close(),None][2]
switch={'input':{},'password':{}}
async def input(p,m,f,*args,**k): # k should not include p m f k id args user channel message
"""
:param p: prompt
:param m: message object
:param f: function to execute on input
:param args: args for f
:param k: kwargs
:return: message object
"""
global switch;msg=await m.channel.send(p)
switch['input'].update({'message':m,'target':f,'args':args,'kwargs':k})
return msg[0]
you see I made an entirely new print function
and a log function to 'actually' print
also, 'actual' input will block the client.run which makes it puke
you wouldn't call it like print tho, but call it once, by itself so it prints the output of the program that it's running in?
you would have "the program that's running" print to a file, then you would read that file if you wanted to know its contents
i.e. either hack print or sys.stdout
you could do
sys.stdout=open('thingy.txt','w+')
then if you needed text in the host window you'd raise error or warning
async def on_ready():__name__=='__main__' and(log(">>> __import__('time').sleep(99999999)\n")or 1)or(not os.system("")and log("\x1b[33mRunning outside of main thread.\x1b[0m"))
async def on_message(message):
not os.system("")and log("\x1b[32mProcessing Data package. id:",message.id.__str__(),'\x1b[0m')
...
oh
also...
async def send(channel,result:str,format='',tts=False):
s=1990-len(format);return[await channel.send(f"{'`'*3}{format}\n".__mul__(format!='')+result[i:i+s]+3*"`".__mul__(format!=''),tts=tts)for i in range(...!=...,len(result),s)]
log=lambda *s,sep=' ',end='\n':os.system("")or sys.__stdout__.write(sep.join(s)+end)
switch={'input':{},'password':{}}
async def input(p,m,f,*args,**k): # k should not include p m f k id args user channel message
__doc__="""
:param p: prompt
:param m: message object
:param f: function to execute on input
:param args: args for f
:param k: kwargs
:return: message object
"""
global switch;msg=await m.channel.send(p)
switch['input'].update({'message':m,'target':f,'args':args,'kwargs':k})
return msg[0]
async def on_message(message):
not os.system("")and log("\x1b[32mProcessing Data package. id:",message.id.__str__(),'\x1b[0m')
global msg,switch;msg=switch['input']and[message.channel,message.author]==[switch['input']['message'].channel,switch['input']['message'].author]and[await send(message.channel(switch['input']['f'](*switch['input']['args'],**switch['input']['k']))),switch.update({'input':{}})][0]or msg
...
so you gotta override a lot of builtin functions to capture the stdout
and I haven't even started trying to protect from 'shell injection'
if you wrote things like "\x1b[32mProcessing Data package. id:",message.id.__str__(),'\x1b[0m' into the shell you mean?
yeah if you wanted to write some flippityfloppityfunnylooking to the shell, you use a different function that writes directly to stdout
either that, or write to a log file, and run a separate process that prints the contents of the file as they appear
something like...
while True:
try:
with open("bot-logs.txt",'r') as file:print((c:=file.read()))
c and open("bot-logs.txt",'w').close()
except FileNotFoundError:exit()
how many functions can you tie together with and that's the first time i've ever seen that used
which is started by something like
__import__('os').system("START /b print-logs.py")
at the start of your file
as long as they can all be interpreted as expressions, you can go as crazy as you like with and and or
if you want to assign a variable in one of these boolean chains...
d = this and [(f:=do_that()),"aaaa"] or (f:=go_crazy())+2
'walrus operator'
anyways i gotta go bye
thanks!
Also...
{print("Low Battery") for I in range(24)}
Will not fill your memory with 24 Nones like if you used [...]
What are some general rules of writing esoteric python and are there any articles to read this about?
well i imagine there's lots of articles and rules about writing normal python, so read those and use that as what not to do when writing esoteric python
if there's something particular you're going for like maximal obfuscation (make code hard to read) or golfing (making the code as short as possible) you can probably find things to help with those specifically
βrulesβ and βesotericβ donβt go too well together :P
Hello.
i did it too π³
still coming up with new ideas though
I wanna make a code generator this, a one line discord.py bot code generator
imagine how awesome that'd be
!e
print(''.join((str(...).lower()[1], str(bool)[10], str(...).lower()[1])))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
lol
making lol with the L from ellipsis, o from bool, and another L from ellipsis
!e
print(chr(int(ord(str(True)[0])).__sub__((True.__int__().__add__(True.__int__()).__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__mul__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True))))))))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
K
playing around with ascii values
creative
What I really want to know is....
!e ```py
k=0
class CursedF(int):
def init(s,*args):s.init=0;super().init(args and args[0]or 0)
def pow(s, n):
if not s.init:s+=n;s.init+=1;return s
else:return CursedF()int.pow(s,n)
def add(s,o=1):return super().add(o,self=s)
cursedf = CursedF()
cursed = cursedfk
print(cursed,cursed.add())
!e ```py
k=0
class CursedF(int):
def init(s):s.init=0;super().init()
def pow(s, n):
if not s.init:s+=n;s.init+=1;return s
else:return CursedF()int.pow(s,n)
def add(s,o=1):return super().add(o,self=s)
cursedf = CursedF()
cursed = cursedfk
print(cursed,cursed.add())
@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 | File "<string>", line 5, in __pow__
004 | File "<string>", line 7, in __add__
005 | TypeError: wrapper __add__() takes no keyword arguments
AAAAAaaaaaaaAaaaaAAaAAAAAAAAAAAAAAAAAAAaa
Fuuuuuuuuyuuuuuuu7uuuuuu77juiyhjg7hirufihdhdjd9dhdhd
That means....
That I can't have an optional other argument in addition definition.
@floral meteor you can but super().__add__(o, self=s) is doing int.__add(o, self=s)
Oh.
Super syntax makes my brain hurt
!e ```py
k=0
class CursedF(int):
def init(s):s.init=0;super().init()
def pow(s, n):
if not s.init:s+=n;s.init+=1;return s
else:return CursedF()int.pow(s,n)
def add(s,o=1):return super().add(o)
cursedf = CursedF()
cursed = cursedfk
print(cursed,cursed.add())
@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 | File "<string>", line 5, in __pow__
004 | AttributeError: 'int' object has no attribute 'init'
print(sum([j[k]for j in[[[r, m.append(list(l.split("= ")[1]))if"X"in l else r.update({l[l.index("[")+1:l.index("]")]:int("".join(map(lambda x:x[1] if x[1] !="X"else x[0],zip([["0"for i in range(len(m[-1])-len(n))]+list(n) for n in[bin(int(l.split("=")[1]))[2:]]][0],m[-1]))),2)})][0]for r in[{}]for m in[[]]for l in open("input.txt").read().split("\n")][0]]for k in j]))``` here's my shitty solution for one part of aoc lel
At least !e so we see what it does lel
make a fake file
if so how lmfao
I.e. redefine open to return a string from .read
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:
!e
So to start you off I'll show you the attributes your CursedOpen class needs to have...
dir(open("f.txt",'w'))
@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 | OSError: [Errno 30] Read-only file system: 'f.txt'
lmfao
!e ```py
print(dir(open))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__']
whachu guys doing?
Hacking bot just hard enough to display the attributes of a file object
Nothing sinister,yet
!e ```py
print(open.class, open.new.code.co_consts)
@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 | AttributeError: 'builtin_function_or_method' object has no attribute '__code__'
Bruh how does a built-in function or method not have a code attribute
!e ```py
import builtins as _
dir(_)
@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 '__builtins__'
Nice
Good bot security, actually
!e ```py
#first, sanity check:
print("<","@!","599422361166413824",">",sep="")
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
<@β!599422361166413824>
Lol
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
No
!e
@terse mortar :warning: Your eval job has completed with return code 0.
[No output]
# let's see how advanced this is...
print("`"*3,"<","@!","599422361166413824",">","`"*3,sep='')
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
!e ```py
let's see how advanced this is...
print(""*3,"<","@!","599422361166413824",">",""*3,sep='')
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Code block escape attempt detected; will not output result
Full output: https://paste.pythondiscord.com/wohotuweda.txt
NIIIIICE
damn
Thou shalt not escape looooooool
!e __import__("sys").os("ls")
@sudden willow :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: module 'sys' has no attribute 'os'
@sudden willow :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: module 'sys' has no attribute 'system'
os
!e ```py
we are esoterically hacking bot lol
print("<","@!","599422361166413824",">",sep='',end=chr(27))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
<@β!599422361166413824>
omfg
!e ```py
print(ord("\"))
!e (__import__("os").system("cd /etc/ && ls"))
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
??
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
92
!e ```py
we are esoterically hacking bot lol
print("<","@!","599422361166413824",">",sep='',end=chr(92))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
<@β!599422361166413824>\
!e
_=["i love boys"] _=_.append(__**2)for __ in _)
bruh
@sudden willow :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | _=_.append(__**2)for __ in _)
003 | ^
004 | SyntaxError: invalid syntax
huh
!e
_=["i love boys"] _=[_.append(__**2)for __ in _]
@sudden willow :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | File "<string>", line 2, in <listcomp>
004 | TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
Hmm
!e
_=["i love boys"] _=[_.append(__*2)for __ in _]
@sudden willow :warning: Your eval job timed out or ran out of memory.
[No output]
oomkiller π₯
!e ```py
print("`"*3)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Code block escape attempt detected; will not output result
Full output: https://paste.pythondiscord.com/sumaxoxebi.txt
!e print("","","",sep='',end='')
!e
print(chr(128)*3)
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
ΒΒΒ
!e print("","","",sep='',end='')
@floral meteor :warning: Your eval job has completed with return code 0.
[No output]
!e print(*['`']*2,sep='',end='')
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
``
!e
print("".join((chr(128)*3)))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
ΒΒΒ
@sudden willow :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: str.join() takes exactly one argument (2 given)
!e print(*['`']*2,sep='`',end='`')
@floral meteor :warning: Your eval job has completed with return code 0.
[No output]
!e
print(chr(128)*3, "hi")
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
ΒΒΒ hi
dafaque
@sudden willow character 127 is DEL
!e print(ord("`"))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
96
96
!e
print(chr(96)*3, "hi")
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
Code block escape attempt detected; will not output result
Full output: https://paste.pythondiscord.com/udobozunen.txt
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
Although I think the filter is
if '`'*3 in message.content: make_file(result); result=error_string("code_block_escape")
And the crazy modules like os are edited to return -1 instead if doing the stuff
I.e....
!e ```py
import('os').remove(file)
@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 '__file__' is not defined
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
-1
See?
damn
this is like the complete opposite of notsobot
in notsobot you can dump every file from it using .rex
including /etc/ data
!e ```py
print(globals())
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}
@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 | AttributeError: 'dict' object has no attribute '__builtins__'
Lol
do you mean dir(globals()["__builtins__"])
!e
print(dir(globals()['builtins']))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError
... (truncated - too long)
Full output: https://paste.pythondiscord.com/nalamahefo.txt
can any one teach me how to connect my .py silent exploit to be reporting on my email ???
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
There's nothing really exploitable in there for bot hack
Could use the names of the errors to build strings tho
!e ```py
class cursed(int):
def add(s,o=1):return super().add(1)
haha=cursed(0)
print(haha)
haha=haha.add()
haha+=3
print(haha)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 4
hello
A
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 2
im new
Yeah this is the advanced channel
Use your brain more, and it will get used to being used, and you will get smarter
but my understanding is bad
!e ```py
class cursed(int):
def add(s,o=1):return cursed(super().add(1))
haha=cursed(0)
print(haha)
haha=haha.add()
haha+=3
print(haha)β
print(haha+)
@floral meteor :x: Your eval job has completed with return code 1.
001 | File "<string>", line 7
002 | print(haha)β
003 | ^
004 | SyntaxError: invalid non-printable character U+200A
Wat
ima go
!e ```py
class cursed(int):
def add(s,o=1):return cursed(super().add(1))
haha=cursed(0)
print(haha)
haha=haha.add()
haha+=3
print(haha)
bye
!e ```py
class cursed(int):
def add(s,o=1):return cursed(super().add(1))
haha=cursed(0)
print(haha)
haha=haha.add()
haha+=3
print(haha+)
@floral meteor :x: Your eval job has completed with return code 1.
001 | File "<string>", line 7
002 | print(haha+)
003 | ^
004 | SyntaxError: invalid syntax
!e ```py
class cursed(int):
def add(s,o=1):return cursed(super().add(1))
haha=cursed(0)
print(haha)
haha=haha.add()
haha+=3
print(haha+...)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 3
How do you syntax argumentless addition?
It tells me invalid syntax but if I chuck a placeholder in there it does what it needs to regardless of the placeholder
What I want to eventually do is exploit commas in arguments, funders including get item and get attribute to return lambdas to get...
k="" # input to the program. Alternatively define __ne__ attribute to bf!="<input>"
bf = Brainf**k # __pow__ is the new __init__
encoded_object = bf(# the following return bf objects with encoded lambdas
bf+++++++++[ # input a list to the previous instruction to add a while loop
bf>++++++++++<-"you could insert any python object here as comments"
]>. # getattr with no input arguments would print
)
print(str(encoded_object)) # string attribute would execute the instructions
But unfortunately the syntax doesn't allow no b argument to a+b
Alright I guess I'll make a cursed English number system instead
.as_integer_ratio() IIRC.
Alright, I got this chunker that prints this, with yellow bars proportional to memory usage. You can input options as binary.
How to golf other than the obvious variable name shortening which is next todo.
def _rat_mat(n):
r=n.as_integer_ratio()
_={(r:=(int(r[0]/100000),int(r[1]/100000)))for _ in iter(lambda:r[0]>1000 and r[1]>1000,False)}
a,b=r
return[*[True]*a,*[False]*b]
class Maybe(int):
r=__import__('random')
def __new__(s,n:float=1.0):s.c=n>0 and _rat_mat(n)or(n<0 and _rat_mat(-1/n))or False;return s.r.choice(s.c)
import os,sys
def print_green(green=1,newlines=1,spaces=1,binary=1,monitor=1,sparse=1,smol=0,suppress_escape=1,*opts):
now=(time:=__import__('time').time)();strain=0.0001
try:os.system("")or{print(("".join([chr((spaces and Maybe(0.2+sparse) and 32)or(binary and Maybe(0.2+0.5*sparse)and(48+1*Maybe()))or sum([Maybe()and 2**j or 0 for j in range(7)]))for i in range(200-100*smol)]).translate(str.maketrans('','',''.join([chr(this)for this in range(2**5)])+''*suppress_escape)))[:~int(strain*100)][:os.get_terminal_size()[0]-10],end=green*'\x1b[0m'+(newlines*'\n')+monitor*(green*'\x1b[33m'+(strain:=-now+(now:=time())).__str__()[:6]+int(strain*100)*'|'*(not smol)+'\x1b[0m'*green))for p in iter(lambda:print(end='\x1b[32m'*green),True)}
except KeyboardInterrupt:print('\x1b[0m')
finally:print('\x1b[0m')
return True
__name__=='__main__'and print_green(*[int(this)for this in input("\n[1111101]\nb>")])or(green_text:=(hexspam:=print_green))and(__doc__:="Make green text go brrrr")
actually, it might be cpu usage it's proportional to
if i shake my mouse it slows down
!e @snow beacon well yes, but a small issue with that...
print(0.1 .as_integer_ratio())
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
(3602879701896397, 36028797018963968)
plus I keep typing as_integer_ratio as as_integer_ration so that adds a backspace i have to type
!e I could try...
from math import ceil
f=0.1
a,b = f.as_integer_ratio()
a,b = int(a),ceil(b*f)//f
print((a/b).as_integer_ratio())
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
(3602879701896397, 36028797018963968)
but that's the same
!e ```py
from math import ceil
f=0.1
a,b = f.as_integer_ratio()
a,b = int(a),ceil(b*f)//f
print(a,b,sep='/',end='=')
print((a/b).as_integer_ratio())
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
3602879701896397/3.602879701896397e+16=(3602879701896397, 36028797018963968)
you can use float.__ceil__ instead of importing from math
oh cool
!e ```py
f=0.1
a,b = f.as_integer_ratio()
a,b = int(a),(b*f).ceil()//f
print(a,b,sep='/',end='=')
print((f:=a/b))
print(f.as_integer_ratio())
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 3602879701896397/3.602879701896397e+16=0.1
002 | (3602879701896397, 36028797018963968)
bruh where's the -2 come from?
That's intended, as far as I know.
I'm working with probability I don't need flippity floppity funny looking when I can have (1, 10)
generated using my obfuscator
!e
"cityshow#0822";(eval("'trollar'"));(eval("'trollar'"));(eval("'trollar'"))
(__import__("base64").b64decode("InN0b3AgdHJ5aW5nIHRvIGNyYWNrIHRoaXMgc2tpZCI="))
_very_real_constant=(__import__("base64").b64decode("InRyb2xlZCI="));_=True.__int__()
(__import__("codecs").decode("uggcf://zrqvn.qvfpbeqncc.arg/nggnpuzragf/781621755261353995/802537966877933578/vzntr0.wct", "rot13"))
True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True.__add__(True))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));"troled"
eval(chr(112)+chr(114)+chr(105)+chr(110)+chr(116)+chr(40)+chr(34)+chr(72)+chr(101)+chr(108)+chr(108)+chr(111)+chr(44)+chr(32)+chr(87)+chr(111)+chr(114)+chr(108)+chr(100)+chr(33)+chr(34)+chr(41)+chr(10)+"")
global trollar;global trollar;global trollar;global trollar;global trollar;global trollar;global trollar;global trollar;global trollar;global trollar;(chr(int(ord(str(True)[0])).__sub__((True.__int__().__add__(True.__int__()).__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__mul__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True))))))))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
!e py print(0.1.as_integer_ratio())
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
(3602879701896397, 36028797018963968)
!e ```py
n=0.1
r=n.as_integer_ratio()
_={(r:=(int(r[0]/1000),int(r[1]/1000)))for _ in iter(lambda:r[0]>1000 and r[1]>1000,False)}
a,b=r
print(n,end='=')
print(a,b,sep='/')
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
0.1=3/36
why not (True.__int__(), True.__int__().__add__(True.__int__().__add__(and on and on and on and on)))
obfuscation by distraction
Why not that, but for (3602879701896397, 36028797018963968)?
i mean that works too
only real part of this code that matters is eval(chr(112)+chr(114)+chr(105)+chr(110)+chr(116)+chr(40)+chr(34)+chr(72)+chr(101)+chr(108)+chr(108)+chr(111)+chr(44)+chr(32)+chr(87)+chr(111)+chr(114)+chr(108)+chr(100)+chr(33)+chr(34)+chr(41)+chr(10)+"")
!e
eval(chr(112)+chr(114)+chr(105)+chr(110)+chr(116)+chr(40)+chr(34)+chr(72)+chr(101)+chr(108)+chr(108)+chr(111)+chr(44)+chr(32)+chr(87)+chr(111)+chr(114)+chr(108)+chr(100)+chr(33)+chr(34)+chr(41)+chr(10)+"")
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
output not input
If you want to round something with a big denominator to a neater fraction, probably continued fractions are the way to go.
actually...
monke think...
!e
Okay i forgot what I was doing halfway through writing it...
n=0.1
r=n.as_integer_ratio()
_={(r:=(int(str(r[0])[:~((len(str(n-n//1))or 2)-2)]),int(str(r[1])[:~((len(str(n-n//1))or 2)-2)])))for _ in iter(lambda:r[0]>1000 and r[1]>1000,False)}
a,b=r
print(n,end=' = ')
print( r, sep='/')
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
0.1 = (36, 360)
hey! it works! sort of... almost... i just need to add a bit of...
made my obfuscation algorithm convert all + to .__add__ aswell
!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!*
Hey @sudden willow!
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:
oh damn
!e
# main function
eval(chr(112).__add__(chr(114).__add__(chr(105).__add__(chr(110).__add__(chr(116).__add__(chr(40).__add__(chr(34).__add__(chr(72).__add__(chr(101).__add__(chr(108).__add__(chr(108).__add__(chr(111).__add__(chr(44).__add__(chr(32).__add__(chr(87).__add__(chr(111).__add__(chr(114).__add__(chr(108).__add__(chr(100).__add__(chr(33).__add__(chr(34).__add__(chr(41).__add__(chr(10).__add__(""))))))))))))))))))))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
!e
okay, now how do I find common factors other than each other?
n=0.1
r=n.as_integer_ratio()
_={(r:=(int(str(r[0])[:~((len(str(n-n//1))or 2)-2)]),int(str(r[1])[:~((len(str(n-n//1))or 2)-2)])))for _ in iter(lambda:r[0]>1000 and r[1]>1000,False)}
r=((r[1]//r[0])*r[0]==r[1])and(1,r[1]//r[0])or(r[0],r[1])
print(n,end=' = ')
print(*r, sep='/')
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
0.1 = 1/10
what if i floor_div'd both sides by 9?
Lenny, how do U make these esoteric things? I always look at this channel and see u big braining
oh that reminds me I had a thonk last night...
!e ```py
class Cursed(int):
def init(s,a,b=0):s.i=b;super().init(a)
mul=lambda s,n:Cursed(super().mul(n),s.i)
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n))
add=lambda s,n:Cursed(int.sub(s,n),s.i)
neg=lambda s:Cursed(0,s.i)+s
and=lambda s,n:Cursed(s)-n
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1);billion=millionthousand;trillion=billion*thousand
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19)
twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90)
print(one-thousand-five-hundred and twenty-seven)
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 8, in <module>
003 | ValueError: int() base must be >= 2 and <= 36, or 0
!e ```py
class test(int):
def init(s,n):print(s,n)
test(4)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
4 4
wtf
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0])
def new(s,):s.i=len()>1 and _[1]or 0;return _[0]
mul=lambda s,n:Cursed(super().mul(n),s.i)
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n))
add=lambda s,n:Cursed(int.sub(s,n),s.i)
neg=lambda s:Cursed(0,s.i)+s
and=lambda s,n:Cursed(s)-n
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1);billion=millionthousand;trillion=billion*thousand
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19)
twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90)
print(one-thousand-five-hundred and twenty-seven)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
13
...
lol nice
1527 != 13 but at least it's not erroring...
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0])
def new(s,):s.i=len()>1 and _[1]or 0;return _[0]
mul=lambda s,n:Cursed(super().mul(n),s.i)
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n))
add=lambda s,n:Cursed(int.sub(s,n),s.i)
neg=lambda s:Cursed(0,s.i)+s
and=lambda s,n:Cursed(s)-n
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1);billion=millionthousand;trillion=billion*thousand
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19)
twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90)
print(one-thousand)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
-999
sub doesn't even work lol
!e ```py
class test(int):
def sub(_,n):return test(super().add(n))
print(test(3)-5)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
8
that worked
bruh how is there another string override?
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0])
def new(s,):s.i=len()>1 and _[1]or 0;return _[0]
mul=lambda s,n:Cursed(super().mul(n),s.i)
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n))
add=lambda s,n:Cursed(int.sub(s,n),s.i)
neg=lambda s:Cursed(0,s.i)+s
and=lambda s,n:Cursed(s)-n
str=lambda s:f"Cursed {'One-'s.i}{super(s,int).str()}"
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1);billion=millionthousand;trillion=billionthousand
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19)
twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90)
print(one,thousand)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
1 1000
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0])
def new(s,):s.i=len()>1 and _[1]or 0;return _[0]
mul=lambda s,n:Cursed(super().mul(n),s.i)
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n))
add=lambda s,n:Cursed(int.sub(s,n),s.i)
neg=lambda s:Cursed(0,s.i)+s
and=lambda s,n:Cursed(s)-n
def str(s):return "Cursed "+"One-"s.i+super().str()
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1);billion=millionthousand;trillion=billionthousand
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19)
twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90)
print(str(one),str(thousand))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
1 1000
its because you return _[0] i think
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0])
def new(s,):s.i=len()>1 and _[1]or 0;return s
mul=lambda s,n:Cursed(super().mul(n),s.i)
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n))
add=lambda s,n:Cursed(int.sub(s,n),s.i)
neg=lambda s:Cursed(0,s.i)+s
and=lambda s,n:Cursed(s)-n
str=lambda s:"Cursed "+"One-"s.i+super().str()
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1);billion=millionthousand;trillion=billionthousand
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19)
twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90)
print(one.str(),thousand.str())
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 10, in <module>
003 | TypeError: unsupported operand type(s) for *: 'type' and 'type'
problem is i get that error when returning s
so I gotta return s.init()?
you need to return a instance from __new__afaik
__new__ is the first method to get called in an object's instantiation. It takes the class, then any other arguments that it will pass along to __init__.
now what?
hmm
oh
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0]) # 2
def new(s,):s.i=len()>1 and [1]or 0;return s.init(*) # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:Cursed(s)-n # 8
str=lambda s:"Cursed "+"One-"s.i+super().str() # 9
hundred=Cursed(100,1);print(hundred);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(one.str(),thousand.str()) # 13
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 10, in <module>
003 | File "<string>", line 3, in __new__
004 | File "<string>", line 2, in __init__
005 | AttributeError: 'int' object has no attribute 'i'
!e ```py
class myint(int):
def init(self, val):
self.val = val
def __new__(cls, val):
return super().__new__(cls, val)
print(type(myint(5)), myint(5))
@broken mesa :white_check_mark: Your eval job has completed with return code 0.
<class '__main__.myint'> 5
@floral meteor this is a normal way to subclass int
maybe you can adjust yours to work similarily
ive tried on my end but you supply 1 as a second arg sometimes wich wont work as a base for int
you need to call super().__new__ not init
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0]) # 2
new=lambda c,:super().new(c,*) # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:Cursed(s)-n # 8
str=lambda s:"Cursed "+"One-"s.i+super().str() # 9
hundred=Cursed(100,1);print(hundred);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(one.str(),thousand.str()) # 13
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 10, in <module>
003 | File "<string>", line 3, in <lambda>
004 | ValueError: int() base must be >= 2 and <= 36, or 0
i got that same error
why does it interpret it as base?
how does it manage to reverse override my second arg?
!e int(100, 1)
@broken mesa :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ValueError: int() base must be >= 2 and <= 36, or 0
but I only pass n from int(n)
as s is already passed, hence super().__init__(n) should take the default base argument
!e ```py
print(int("42",0))
@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: int() can't convert non-string with explicit base
i think when you call super.new it calls int.init not Cursed.init
any particular reason for subclassing int?
!e ```py
class Cursed(int):
def init(s,):s.i=len()>1 and [1]or 0;super().init([0]) # 2
new=lambda c,:(s:=super().new(c,*))and Cursed.init(s,_) # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:(s.i or isinstance(n,Cursed)and n.i)and Cursed(sn)or Cursed(int.add(s,n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:Cursed(s)-n # 8
str=lambda s:"Cursed "+"One-"s.i+super().str() # 9
hundred=Cursed(100,1);print(hundred);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billion*thousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(one.str(),thousand.str()) # 13
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 10, in <module>
003 | File "<string>", line 3, in <lambda>
004 | ValueError: int() base must be >= 2 and <= 36, or 0
Well, since I'm overriding all the methods I'm using it's kinda pointless isn't it?
its like an integer but not
that was my line of thought yea
you wouldn't even need new if it was a normal object
I'd need an __int__ attribute tho
can just add that yourself?
and I'd need to use s.val instead of s
i think i tried that already and got has no attirbute i..
i'll try it again tho
you need to make a instance using the super call first
methinks
whats the second arg (of Cursed) supposed to mean anyways?
the second arg is meant to make one-hundred evaluate as 1*100 instead of 1+100
niiiiiice
wait
!e ```py
class Cursed(int):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:"Cursed "+super().str() # 9
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(four-hundred and twenty) # 13
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Cursed 20
oh I see what's wrong
__and__ dunder doesn't work
!e ```py
class test(int):
and=lambda s,n:s+n
print(test(1) and test(2))
print(test(1)&test(2))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 2
002 | 3
i see
__and__(self, other)
Implements bitwise and using the & operator.
I can't use the and keyword then
!e ```py
class Cursed(int):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:"Cursed "+super().str() # 9
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(four-hundred & twenty) # 13
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Cursed 420
but i can override __bool__ itself
lemme redefine keywords please
although not cursed_boolean would still return a boolean regardless
unless...
nope.
very
now im thinking about eso python i wanna finish my functions-are-actual-classes thing
ree
yeah i thought that a bit
!e ```py
class my_func:
def init(*args):print(*args)
my_func(4)
def my_func(*args):print(*args)
my_func(4)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | <__main__.my_func object at 0x7f5dc7d4efd0> 4
002 | 4
!e ```py
class Cursed(int):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:"Cursed "+super().str() # 9
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(eight-thousand-five-hundred & twenty-seven) # 13
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Cursed 800527
that's eight hundred thousand
oh no...
!e ```py
class Cursed(int):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:"Cursed "+super().str() # 9
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(eight-thousand & five-hundred & twenty-seven) # 13
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Cursed 8527
!e ```py
class Cursed(int):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:"Cursed "+super().str() # 9
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(eight-hundred-thousand & four) # 13
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Cursed 800004
ty
!e even more applicable is if i did a small tweak... ```py
class Cursed(int):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
print(eval("eight-thousand & five-hundred & twenty-seven")) # 13
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
8527
oh true
ah, but then I'd have to call it
unless...
I made it return another version of the Cursed class
just define a __getattr__
oh, k
you will need to figure out a way to handle operator precedence tho
idea: make the class bootstrap itself by adding instances to global scope in a classmethod
!e ```py
class haha:
def init(s,i):s.i=i
def getattr(s,n=0):return s.i[n]
haha([3,4,5]).5
@floral meteor :x: Your eval job has completed with return code 1.
001 | File "<string>", line 4
002 | haha([3,4,5]).5
003 | ^
004 | SyntaxError: invalid syntax
aww
that way you could simultaneously store the instances in the class for usage in getattr
yea attributes need to be valid identifiers
!e ```py
class haha:
def init(s,i):s.i=i
def getattr(s,n="a0"):return s.i[int(n.strip('a'))]
print(haha([3,4,5]).a2)
no print
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
5
huh, so... modified version...
i got it
!e ```py
class Cursed(int):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:"Cursed "+super().str() # 9
def getattr(s, k):
return s.stuff[k]
@classmethod
def bootstrap():
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billionthousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
_.stuff = locals()
globals().update(locals())
Cursed._bootstrap()
print(hundred.thousand)
@broken mesa :white_check_mark: Your eval job has completed with return code 0.
Cursed 1000
well
not decimal yet
but proof of concept
@floral meteor what you think?
cursed enough?
updating globals with locals is next level cursedness
i might have to use that more
HAH I GOT INSTANCES PROPERLY PASSING IN MY FUNC CLASSES
yesssss
!e ```py
class Cursed(float):
def gatattr(s,a):
if s.k:eval(f"{s}.{a}")
else:s.k=1;return Cursed(s-eval(a),d=1)
def init(s,a,d=0):super().init() # 2
def new(c,a,b=0,d=0):s=super().new(c,a);s.i=b;s.k=d;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i,d=isinstance(n,float)) # 4
def sub(s,n):
if not s.k:return Cursed((isinstance(n,Cursed)and n.i)and sn or int.add(Cursed(s),n))
else:s.k/=10;return Cursed(float.add(s,eval(str(n))s.k))
add=lambda s,n:Cursed(int.sub(s,n),s.i) # 6
neg=lambda s:Cursed(0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:s.k and super().str()or int.str(s) # 9
@classmethod
def bootstrap():
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=millionthousand;trillion=billion*thousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
globals().update(locals())
Cursed._bootstrap()
print(eight-thousand & five-hundred & twenty-seven.three) # 13
yea those are indented into the bootstrap method ofc
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 22, in <module>
003 | AttributeError: 'Cursed' object has no attribute 'three'
you need to store the locals in the class like i did
_.stuff = locals()
i store them in stuff
on a scale of 1 to 10 how fucked is this?
!e
about 4
class Cursed(float):
def __gatattr__(s,a):
if s.k:raise SyntaxError
else:s.k=1;return Cursed(s-eval(a),d=1)
def __init__(s,*a,d=0):super().__init__() # 2
def __new__(c,a,b=0,d=0):s=super().__new__(c,a);s.i=b;s.k=d;return s # 3
__mul__=lambda s,n:Cursed(super().__mul__(n),s.i,d=isinstance(n,float)) # 4
def __sub__(s,n):
if not s.k:return Cursed((isinstance(n,Cursed)and n.i)and s*n or int.__add__(Cursed(s),n))
else:s.k/=10;return Cursed(float.__add__(s,eval(str(n))*s.k))
__add__=lambda s,n:Cursed(int.__sub__(s,n),s.i) # 6
__neg__=lambda s:Cursed(0,s.i)+s # 7
__and__=lambda s,n:s-n # 8
__str__=lambda s:s.k and super().__str__()or int.__str__(s) # 9
@classmethod
def _bootstrap(_):
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 10
billion=million*thousand;trillion=billion*thousand # 11
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 12
_.stuff=locals()
globals().update(locals())
Cursed._bootstrap()
print(eight-thousand & five-hundred & twenty-seven.three) # 13
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 23, in <module>
003 | File "<string>", line 13, in <lambda>
004 | File "<string>", line 9, in __sub__
005 | TypeError: descriptor '__add__' requires a 'int' object but received a 'Cursed'
only 4? but i define a method for a function!
ye
mebbe 5
since we can't yet figure out how to make it like a float, probs 3
i mean, i haven't figured out magic methods either
probably cant
without actually converting it to a class
which would be easy in comparison
and cheating
it is a class rn tho?
well a function object
im referring to my thing
ahh ok
!e
print(chr(ord(True.__str__()[0]).__sub__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__()))))))))))))).__add__(chr(ord(True.__str__()[1]).__sub__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True.__int__().__add__(True))))))))))))))).__add__((....__class__().__str__())[2]).__add__(....__class__().__str__()[2]).__add__(chr(ord(True.__str__()[1]).__sub__(True.__int__().__add__(True.__int__().__add__(True.__int__()))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
Hello
took a good 30 minutes to code
!e ```py
class Cursed(float):
def init(s,a):super().init() # 2
def new(c,a,b=0):s=super().new(c,a);s.i=b;return s # 3
mul=lambda s,n:Cursed(super().mul(n),s.i) # 4
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or isinstance(n,float)and(float.add(s,n))or int.add(Cursed(s),n)) # 5
add=lambda s,n:Cursed(super().sub(n),s.i) # 6
neg=lambda s:Cursed(0.0,s.i)+s # 7
and=lambda s,n:s-n # 8
str=lambda s:super().str() # 9
def getattr(s, k):return Cursed(eval(str(s))+s.stuff[k]0.1) # 10
@classmethod
def bootstrap():
hundred=Cursed(100,1);thousand=Cursed(1000,1);million=Cursed(1000000,1) # 13
billion=millionthousand;trillion=billion*thousand # 14
one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=Cursed(1),Cursed(2),Cursed(3),Cursed(4),Cursed(5),Cursed(6),Cursed(7),Cursed(8),Cursed(9),Cursed(10),Cursed(11),Cursed(12);thirteen,forteen,fifteen,sixteen,seventeen,eighteen,nineteen=Cursed(13),Cursed(14),Cursed(15),Cursed(16),Cursed(17),Cursed(18),Cursed(19);twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=Cursed(20),Cursed(30),Cursed(40),Cursed(50),Cursed(60),Cursed(70),Cursed(80),Cursed(90) # 15
_.stuff = locals() # 16
globals().update(locals()) # 17
Cursed._bootstrap() # 18
print(one-hundred & three.seven) #19
lol
i can believe that
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
103.7
wow that works
nice
but only for one decimal place
had alot of eof errors
I've got an esoteric score of 207!
ye
hmm
that's the esoteric score, sΓ?
i mean not really?
I mean really, considering the more weak warnings there are, generally the more esoteric the code is
aww, my linter thinks he function doesn't return.
no it returns a instance of itself
Have you seen my esoterically written basic resmon?
def _rat_mat(n):
r=n.as_integer_ratio()
_={(r:=(int(r[0]/100000),int(r[1]/100000)))for _ in iter(lambda:r[0]>1000 and r[1]>1000,False)}
a,b=r
return[*[True]*a,*[False]*b]
class Maybe(int):
r=__import__('random')
def __new__(s,n:float=1.0):s.c=n>0 and _rat_mat(n)or(n<0 and _rat_mat(-1/n))or False;return s.r.choice(s.c)
import os,sys
def print_green(green=1,newlines=1,spaces=1,binary=1,monitor=1,sparse=1,smol=0,suppress_escape=1,*opts):
now=(time:=__import__('time').time)();strain=0.0001
try:os.system("")or{print(("".join([chr((spaces and Maybe(0.4+sparse) and 32)or(binary and Maybe(0.2+0.5*sparse)and(48+1*Maybe()))or sum([Maybe()and 2**j or 0 for j in range(7)]))for i in range(200-100*smol)]).translate(str.maketrans('','',''.join([chr(this)for this in range(2**5)])+''*suppress_escape)))[:~int(strain*100)][:os.get_terminal_size()[0]-10],end=green*'\x1b[0m'+(newlines*'\n')+monitor*(green*'\x1b[33m'+(strain:=-now+(now:=time())).__str__()[:6]+int(strain*100)*'|'*(not smol)+'\x1b[0m'*green))for p in iter(lambda:print(end='\x1b[32m'*green),True)}
except KeyboardInterrupt:print('\x1b[0m')
finally:print('\x1b[0m')
return True
__name__=='__main__'and print_green(*[int(this)for this in input("\n[1111101]\nb>")])or(green_text:=(hexspam:=print_green))and(__doc__:="Make green text go brrrr")
If i move the cursor erratically around the screen, it slows it down and extends the yellow bars. Same as if i resize a window or start a process
i like
ty, init takes binary arguments to switch features on or off
but back to what we were talking about previously: i dont think linter errors are a proper measurement for esotericness of code
its about the extremes of bad practices you use, not the amount of pep 8 infringements.
i could write very non-esoteric code that breaks pep8 a thousand times
simply by printing a thousand strings that are longer than 79 characters
this is the urandom generator that runs this
and the yellow bars are proprotional to how long it takes to print that with extra spaces, 1s and 0s
and formatted green
and themselves
and the former chopped to allocate room for the yellow text and to keep within terminal size
sometimes it manages to undergo two cycles in less than 0.0001 time, in which case it displays as 0.0
I could probably make a version that instead of printing green text, it clears the screen each cycle, and displays miscellaneous bars for different processes
is there any pep discussing the non-isolation of private datatypes?
That's more of a question for #internals-and-peps
alright π
what code do i use to compute all multiples of 3, 5 that are less than 100 in python??
that sounds like a terribly worded fizzbuzz
my very lazy solution
!e ```py
print(list(dict.fromkeys(sorted([i for i in range(0, 100, 3)]+[i for i in range(0, 100, 5)]))))
@frozen holly :white_check_mark: Your eval job has completed with return code 0.
[0, 3, 5, 6, 9, 10, 12, 15, 18, 20, 21, 24, 25, 27, 30, 33, 35, 36, 39, 40, 42, 45, 48, 50, 51, 54, 55, 57, 60, 63, 65, 66, 69, 70, 72, 75, 78, 80, 81, 84, 85, 87, 90, 93, 95, 96, 99]
I would just do
print([n for n in range(100) if (n % 3) * (n % 5) == 0])
print([n for n in range(100) if n%15 in b'\x00\x03\x05\x06\t\n\x0c'])
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
<frame at 0x7f04c22fe740, file '<string>', line 12, code <module>>
works the same as sys._getframe without needing an import
b'\0\03\05\06' works too, if I'm right
don't remember the exact semantics for octal escapes
!e
_=[print(....__class__().__str__()[_]) for _ in range(len(....__class__().__str__))]
@sudden willow :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: object of type 'method-wrapper' has no len()
!e
_=[print(....__class__().__str__()[_]) for _ in range(len(....__class__().__str__()))]
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | E
002 | l
003 | l
004 | i
005 | p
006 | s
007 | i
008 | s
fixed ur welcome @sudden willow
@sick hound thx
@sick hound how tf does that work
its very easy
also not my code
ask cityshow
I understand most of it
but what are the 4 dots before __class
it's three dots (ellipsis) followed by dot notation
ah
!e ```py
enigma_en=lambda s,k:{k:(k:=len(s)<len(k)and key[:len(s)]or len(s)>len(k)and(k*(len(s)//len(k)+1))[:len(s)]or k),k:(_s:=[ord(c)for c in list(s)]),k:(k:=[ord()for _ in list(k)]),k:[(_p:=[]),{_p.append((((-32)+(k[]-32))%95)+32)for , in enumerate(s)}],k:s.class().join([chr()for _ in _p])}[k]
print((_6:=enigma_en("haha password go brrrrrr","Password1")))
enigma_de=lambda s,k:{k:(k:=len(s)<len(k)and key[:len(s)]or len(s)>len(k)and(k*(len(s)//len(k)+1))[:len(s)]or k),k:(_s:=[ord(c)for c in list(s)]),k:(k:=[ord()for _ in list(k)]),k:[(_p:=[]),{_p.append((((-32)-(k[]-32))%95)+32)for , in enumerate(s)}],k:s.class().join([chr()for _ in _p])}[k]
print(enigma_de(_6,"Password1"))
print(enigma_de(_6,"wrong password"))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 9C\Uw`TX%HQfXwWbdsCTffjb
002 | haha password go brrrrrr
003 | APlf0`cv1TYve3_ot%[Tu%vn
I should throw this in my cursed module and curse it a bit
alright I just made this, but I feel like there's some holes in the security
class Enigma(object):
enigma_en=lambda _6,s,k:{k:(k:=len(s)<len(k)and k[:len(s)]or len(s)>len(k)and(k*(len(s)//len(k)+1))[:len(s)]or k),k:(_s:=[ord(c)for c in list(s)]),k:(_k:=[ord(_)for _ in list(k)]),k:[(_p:=[]),{_p.append((((__-32)+(_k[_]-32))%95)+32)for _,__ in enumerate(_s)}],k:s.__class__().join([chr(_)for _ in _p])}[k]
enigma_de=lambda _6,s,k:{k:(k:=len(s)<len(k)and k[:len(s)]or len(s)>len(k)and(k*(len(s)//len(k)+1))[:len(s)]or k),k:(_s:=[ord(c)for c in list(s)]),k:(_k:=[ord(_)for _ in list(k)]),k:[(_p:=[]),{_p.append((((__-32)-(_k[_]-32))%95)+32)for _,__ in enumerate(_s)}],k:s.__class__().join([chr(_)for _ in _p])}[k]
def __init__(_,s='',k=''):_._k=k;_._s=s
__str__=lambda _:_.enigma_en(_._s,_._k)
__getattribute__=__getattr__=lambda _,n:n in['enigma_en','enigma_de','__str__']and super().__getattribute__(n)or n
__setattr__=lambda _,n,s:int(not (n in['key','password']and[super().__setattr__('_k',s),1][1]or n in['source','token']and[super().__setattr__('_k',s),1][1]or 0))
detokenise=lambda _,s:s.replace(_._s,:"<token>")
retokenise=lambda _,s:s.replace("<token>",._._s)
@broken mesa
I have figured out how to implement and in natural syntax for numbers, but i don't have time rn to make it.
essentially, I would create a CursedCore class to store data, with a value attribute initialised at 0 and a get_value method that reinitialises it when it returns the value, then I would do cc = CursedCore() and pass cc as an argument to the Cursed objects, then i'll define __bool__ such that the value of the Cursed object is added to cc.value, then __str__(self) would return self-self.cc.get_value().
so...
print(str(
four-hundred and twenty
))
would first evaluate four-hundred 4*100 then bool(result) would add 400 to cc.value, and return True to the and, so that twenty 20 gets evaluated. Then the expression is 'stringed' which would add cc.value to twenty, reset cc.value, and return the string of the new value, '420' to the print function
big brain go brrrrr
If the source code is distributed and this is able to be accessed then thats a security hole. Most if not all code can be deobfuscated by someone who truely wants to
Sure itll stop the average user, but for people who'd be diving into it in the first place its just an extra few steps
@dull anvil I pinged you here because it's not really something that you should do in Python, but here is a way to have it sum up values without globals:
import inspect
import copy
def chain_sum(val=None):
self = globals()[inspect.stack()[0][3]]
if val is None:
result = self._val_
self._val_ = 0
return result
if not hasattr(self, "_val_"):
setattr(self, "_val_", val)
return self
else:
self._val_ += val
return self
print(chain_sum(5)(3)(6)())
print(chain_sum(5)(3)(8)())
ooooh
the _val_ attribute should really be added before the function is even called, but I wanted it to be self-contained
ah got it
because it's not really something that you should do in Python
Iβve seen worst production code haha
Maybe with some even more hacky code one could introspect when the chain ends
So the last function call with the empty argument isn't necessary
def chain_sum(n):
def summer(m=None):
if m is None:
return n
else:
return chain_sum(n+m)
return summer
``` seems like an easier implementation
Yeah, this is definitely better
Hmm, can anyone think of a good way to make it work without the terminating empty argument?
class chain_sum(int):
def __call__(self, other):
return chain_sum(self + other)
though this wouldn't work with arbitrary objects, only with ints
Oh this is great
Here's my extremely ungodly solution ```py
import inspect
import linecache
def chain_sum(val):
self_name = inspect.stack()[0][3]
caller_frame = inspect.getframeinfo(inspect.stack()[1][0])
caller_lineno = caller_frame.lineno
caller_filename = caller_frame.filename
calling_line = linecache.getline(caller_filename, caller_lineno)
if calling_line.count(self_name) != 1:
raise SyntaxError("This function can't be called more than once per line.")
idx = calling_line.index(self_name) + len(self_name)
calls_amount = 0
nest = 0
for c in calling_line[idx:]:
if c == "(":
if nest == 0: calls_amount += 1
nest += 1
elif c == ")":
nest -= 1
if nest == -1: break
if nest == 0 and c not in "() ":
break
def chain_sum(n, depth):
if depth == 0:
return n
def summer(m):
return chain_sum(n+m, depth - 1)
return summer
return chain_sum(val, calls_amount - 1)
But it should do arbitrary objects
but don't you call another function in it's arguments fixed, I think
indeed
!eval ```py
x, y = 0, 0
def foo():
x, y = 1, 1
class C:
print(x, y)
x = 2
foo()
@wispy forge :white_check_mark: Your eval job has completed with return code 0.
0 1
why in the f
!eval ```py
x, y = 0, 0
def foo():
x, y = 1, 1
class C:
print(x, y)
foo()
@wispy forge :white_check_mark: Your eval job has completed with return code 0.
1 1
Help me understand
calculator supporting arbitrary expressions (no functions) in one line
compile(input("enter expression"),'','eval').co_consts[0]
``` (wonder if it can be broken somehow)
!e
print(compile('10*88+(88-8)','','eval').co_consts[0])
@proper vault :white_check_mark: Your eval job has completed with return code 0.
960
Interesting
!e
noreply@gmail.com```
@soft prairie :white_check_mark: Your eval job has completed with return code 0.
noreply@gmail.com
Fun
!e ```py
import sys
sentinel = object()
class Site:
def init(self, name, orig):
self.name = name
self.orig = orig
def getattr(self, _):
del globals()[self.name]
if self.orig is not sentinel:
globals()[self.name] = self.orig
class EmailMeta(type):
def getattr(cls, usr):
frame = sys.getframe(1)
f_code = frame.f_code
instr = frame.f_lasti + 2
site, ext, * = map(
f_code.co_names.getitem,
f_code.co_code[instr+1::2]
)
orig = globals().get(site, sentinel)
globals()[site] = Site(site, orig)
return cls(usr, site, ext)
class email(metaclass=EmailMeta):
def init(self, usr, site, ext):
self.usr, self.site, self.ext = usr, site, ext
def __matmul__(self, _):
return self
def __repr__(self):
return f'{self.usr}@{self.site}.{self.ext}'
print(email.noreply@gmail.com)```
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
noreply@gmail.com
!e
endl = "\n"
x = 10
cout << "hi" << x << endl;```
@soft prairie :white_check_mark: Your eval job has completed with return code 0.
hi10
!e
endl = '\n'
cout = 'cout'
_ = type('',(),{'__getitem__': lambda s, _: getattr(_.start, _.step)})()
std = type('',(),{'cout': type('',(),{'__lshift__': lambda s, i: (__import__('sys').stdout.write(i), s)[1]})()})
_[std::cout] << 'Hello world' << endl << 'lol' << endl;
@steep mural :white_check_mark: Your eval job has completed with return code 0.
001 | Hello world
002 | lol
!e ```py
class Cursed(float):
class CursedCore:
def init(self):self.value=Cursed(0.0,cc=self);self.n=0
def call(self,n):self.n=n/2;return self
def get_value(self):=self.value;self.init();return Cursed(,cc=self)
def bool(self):self.value-=self.n;self.n=0;return False
def init(s,_a,**_k):super().init()
def new(c,a,b=0,cc=None):s=super().new(c,a);s.i=b;s.cc=cc;return s
mul=lambda s,n:Cursed(super().mul(n),s.i,s.cc)
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or super().add(n10**-s._numdec()),cc=s.cc)
add=lambda s,n:Cursed(super().sub(n),s.i,s.cc)
neg=lambda s:Cursed(0.0,s.i,s.cc)+s
and=lambda s,n:s-n
_getstr=lambda s:super(float,s).str()
_numdec=lambda s:0 if s.getstr().endswith('0')else len(s.split('.')[1])
str=lambda s:super(Cursed,s-s.cc.get_value()).str()
bool=lambda s:not s.cc(s)
def getattr(s, k):return Cursed(eval(s.get_str())+s.stuff[k]*0.1)
@classmethod
def bootstrap():
cc=.CursedCore()
hundred=Cursed(100,1,cc);thousand=Cursed(1000,1,cc);million=Cursed(1000000,1,cc)
billion=millionthousand;trillion=billionthousand;quadrillion=billionmillion;septillion=quadrillionbillion
zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=(Cursed(,cc=cc)for _ in range(13));thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen=(Cursed(,cc=cc)for _ in range(13,20));twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=(tenCursed(_,cc=cc)for _ in range(2,10))
_.stuff = locals()
globals().update(locals())
Cursed._bootstrap()
print(five-hundred and forty-eight)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
548.0
@broken mesa
python: you can't change what and does
me: watch me
LMAO but NICE!
now I'll get these decimals working without recursion errors
ah, _bootstrap doesn't effect globals when imported
so I tweaked bootstrap a little so I can do this
okay now it's acting especially cursed:
from cursed import Cursed as _
globals().update(_._bootstrap())
five.eight
5.8
five.eight-eight
6.6
five.eight-eight-eight
7.3999999999999995
five.eight-eight-eight-eight
7.4
five.eight-eight-eight-eight-eight
8.200000000000001
five.eight-eight-eight-eight-eight-eight
8.20000000000001
five.eight-eight-eight-eight-eight-eight-eight
8.20000000000009
five.eight-eight-eight-eight-eight-eight-eight-eight
8.20000000000017
okay now it adds .8 each time
__
!e ```py
class Cursed(float):
class CursedCore:
def init(self):self.value=Cursed(0.0,cc=self);self.n=0
def call(self,n):self.n=n/2;return self
def get_value(self):=self.value;self.init();return Cursed(,cc=self)
def bool(self):self.value-=self.n;self.n=0;return False
def init(s,_a,**_k):super().init()
def new(c,a,b=0,cc=None):s=super().new(c,a);s.i=b;s.cc=cc;return s
mul=lambda s,n:Cursed(super().mul(n),s.i,s.cc)
sub=lambda s,n:Cursed((isinstance(n,Cursed)and n.i)and sn or super().add(n0.1**s._numdec()),cc=s.cc)
add=lambda s,n:Cursed(super().sub(n),s.i,s.cc)
neg=lambda s:Cursed(0.0,s.i,s.cc)+s
and=lambda s,n:s-n
_getstr=lambda s:super(float,s).str()
_numdec=lambda s:0 if s._getstr().endswith('.0')else len(s._getstr().split('.')[1])+1
str=lambda s:super(Cursed,s-s.cc.get_value()).str()
bool=lambda s:not s.cc(s)
def getattr(s,k):return Cursed(eval(s.getstr())+s.stuff[k]*0.1,s.i,s.cc)
@classmethod
def bootstrap():
cc=.CursedCore()
hundred=Cursed(100,1,cc);thousand=Cursed(1000,1,cc);million=Cursed(1000000,1,cc)
billion=millionthousand;trillion=billionthousand;quadrillion=billionmillion;septillion=quadrillionbillion
zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve=(Cursed(,cc=cc)for _ in range(13));thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen=(Cursed(,cc=cc)for _ in range(13,20));twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety=(tenCursed(_,cc=cc)for _ in range(2,10))
_.stuff = locals()
return locals()
globals().update(Cursed._bootstrap())
print(forty-seven.four-seven-two)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
47.472
okay, @broken mesa I'm stuck on this one:
if i don't do the /2, the first one will return 800
sorry, im already helping in like 2 channels so im kinda busy and not in the mindset for esoteric right now
k i'll give them a look then
420 go brrrrr
i thought using "and" in numbers was incorrect
isn't it just "four hundred twenty"?
nvm im wrong
hmm, I always learned it as "'and' replaces the decimal point"
like, 4 and a third?
I say numbers like "four hundred and twenty eight point seven six" for 428.76
Now change it to "four hundred twenty eight and seventy six hundredths"
^ what i learned in school
though i usually just say "four hundred twenty eight point seven six"
https://www.grammarbook.com/numbers/numbers.asp this link seems overly pretentious so i'll just leave it here
# float modulus go brrrr
__mod__ = lambda s,n:[{(s:=s-n)for __ in iter(lambda:s>n,False)},s][1]
the sign was wrong cos i pulled it from the Cursed class lol
class CursedFloat(float):
__add__=lambda s,n:super(float,s).__sub__(n)
__sub__=lambda s,n:super(float,s).__add__(n)
__mod__=lambda s,n:[{(s:=s+n)for __ in iter(lambda:s>n,False)},s][1]
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Starting...ERROR: name '_rat_mat' is not defined
!e ```py
def r(n):r=n.as_integer_ratio();={(r:=(int(r[0]/100000),int(r[1]/100000)))for _ in iter(lambda:r[0]>1000 and r[1]>1000,False)};a,b=r;return[[True]a,[False]b]
class Maybe(int):
r=import('random')
def new(s,n:float=1.0):s.c=n>0 and _r(n)or False;return s.r.choice(s.c)
bool=lambda s:s.r.choice(s.c);str=lambda s:s and"Maybe True"or"Maybe False";int=lambda s:s and 1 or 0
import os
def print_green(green=1):
now,strain=(time:=import('time').time)(),0.0001
try:green and os.system("")or{print(("".join([chr((Maybe(1.2)and 32)or(Maybe(0.8)and(48+Maybe()))or sum([Maybe()and 2j or 0 for j in range(7)]))for _i in range(200)]).translate(str.maketrans('','',''.join([chr(this) for this in range(25)])+chr(127))))[int(strain100):int(100)-8],end=green'\x1b[0m\x1b[33m'+'\r\n'+(strain:=-now+(now:=time())).str()[:6]+int(strain100)'|'+'\x1b[0m'green)for p in iter(lambda:print(end='\x1b[32m'green),True)}
except KeyboardInterrupt:print(green'\x1b[0m'or'Interrupted')
except Exception as err: print(green'\x1b[0m'or'ERROR:',err)
return True
print_green(0)
@floral meteor :x: Your eval job timed out or ran out of memory.
001 | I , 0 # 1 1 %R F110Q0 000 Y00 _ 00 uI1 0 0 0iw 0 H00w1 ] )G J
002 | 0.0052 P %0{ 0q aq0 ] 1 A | 10 0 1 *0Y 0H0 f _ G"]00^ 0 1 0 y L
003 | 0.00420 10/ x 0 8 1" 0 401 Ef 10B1+ 1 h G+ ~ :8 0 1 `1 A-0 170 t 0 1
004 | 0.0040 0 00 80 1 1R 0 0q :' 1 0 0 1 ^8 = 0 ( 11 t1 01 1 z00n
005 | 0.00410 011 0 0M sU1 1 [0B'0 10 ^ m1 1 11 0 0* T 0 1 D0 1 S 1 0O l 0 1g
006 | 0.004100 1;$ 0R{ 110 :0 B 11 k0 k 12 : u07* 0 _ 0 j0 L e =G ?
007 | 0.004000]} 00 hb e[ 3c 1 1 A 1Y ]61000 1 4?10e 1 c> 0 o r 0 1 0O 0j T 0
008 | 0.0044 01 & ]00 0 ~ 1 I k / B0<"1~ 1 1 01o 0 !1 0 0 9 00, 11(E0 @
009 | 0.0036 :1 1 11 1 10 0V 1 1 01 1 ;1 01 8 10 hN 1 ,A 01
010 | 0.0039 c 1 00 1 < 0 001 @0 s 0 0 0 0
... (truncated - too long, too many lines)
Full output: too long to upload
The fuck
it's missing the bars
the bot can't output colour, and get_terminal_size is invalid
that code when run locally prints this:
!e
a = [1, 2, 3]
for i in a:
print(i)
if i == 2:
s = []
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | 3
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | 3
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | here
004 | 3
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
???
alright then
[i.append(input("y/n: ")) for i in [[input("y/n: "]] for j in i if j == "y"]```
!e
[i.append(input("y/n: ")) for i in [[input("y/n: "]] for j in i if j == "y"]```
@sick hound :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | [i.append(input("y/n: ")) for i in [[input("y/n: "]] for j in i if j == "y"]
003 | ^
004 | SyntaxError: closing parenthesis ']' does not match opening parenthesis '('
!e
[i.append(input("y/n: ")) for i in [[input("y/n: ")]] for j in i if j == "y"]```
@sick hound :x: Your eval job has completed with return code 1.
001 | y/n: Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | EOFError: EOF when reading a line
you can't input to bot
give it dummy input
Also #bot-commands exists too lol
!e ```py
import random
class Input:
def init(self):pass
def call(self,s):print(s);return random.choice(['y','n'])
input=Input()
{i.append(input("y/n: ")) for i in [[input("y/n: ")]] for j in i if j == "y"}
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
y/n:
hmm
!e ```py
import random
class Input:
def init(self):pass
def call(self,s):print(s,end='');print((c:=random.choice(['y','n'])));return c
input=Input()
i='y'
{print((i:=input('y.n: '))) for _ in iter(lambda: i=='y',False)}
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | y.n: y
002 | y
003 | y.n: y
004 | y
005 | y.n: n
006 | n
(lambda _, __, ___, ____, _____, ______, _______, ________:
getattr(
__import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
().__class__.__eq__.__class__.__name__[:__] +
().__iter__().__class__.__name__[_:][_____:________]
)(
_, (lambda _, __, ___: _(_, __, ___))(
lambda _, __, ___:
bytes([___ % __]) + _(_, __, ___ // __) if ___ else
(lambda: _).__code__.co_lnotab,
_ << ________,
(((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
- _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
__) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
<< ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
__) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
<< (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
_) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
(((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
_))) + (_____ << ______) + (_ << ___)
)
)
)(
*(lambda _, __, ___: _(_, __, ___))(
(lambda _, __, ___:
[__(___[(lambda: _).__code__.co_nlocals])] +
_(_, __, ___[(lambda _: _).__code__.co_nlocals:]) if ___ else []
),
lambda _: _.__code__.co_argcount,
(
lambda _: _,
lambda _, __: _,
lambda _, __, ___: _,
lambda _, __, ___, ____: _,
lambda _, __, ___, ____, _____: _,
lambda _, __, ___, ____, _____, ______: _,
lambda _, __, ___, ____, _____, ______, _______: _,
lambda _, __, ___, ____, _____, ______, _______, ________: _
)
)
)
that's pretty fun lol
ahh brainfuck in python
ikr lmfao, obfuscation
while (i:=input('y/n: ')) == 'y': print(i)
what does that even do
if you run it, it outputs "hello world' iirc
!e
(lambda _, __, ___, ____, _____, ______, _______, ________:
getattr(
__import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
().__class__.__eq__.__class__.__name__[:__] +
().__iter__().__class__.__name__[_:][_____:________]
)(
_, (lambda _, __, ___: _(_, __, ___))(
lambda _, __, ___:
bytes([___ % __]) + _(_, __, ___ // __) if ___ else
(lambda: _).__code__.co_lnotab,
_ << ________,
(((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __)
- _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ <<
__) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______
<< ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) <<
((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) <<
__) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______
<< (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) +
_) << ((((___ << __) + _) << _))) + (((_______ << __) - _) <<
(((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ <<
_))) + (_____ << ______) + (_ << ___)
)
)
)(
*(lambda _, __, ___: _(_, __, ___))(
(lambda _, __, ___:
[__(___[(lambda: _).__code__.co_nlocals])] +
_(_, __, ___[(lambda _: _).__code__.co_nlocals:]) if ___ else []
),
lambda _: _.__code__.co_argcount,
(
lambda _: _,
lambda _, __: _,
lambda _, __, ___: _,
lambda _, __, ___, ____: _,
lambda _, __, ___, ____, _____: _,
lambda _, __, ___, ____, _____, ______: _,
lambda _, __, ___, ____, _____, ______, _______: _,
lambda _, __, ___, ____, _____, ______, _______, ________: _
)
)
)```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
Hello world!
wack
I get hated on when I do complex one liners lmao
one person got mad at me just for having an if and its body in the same line
lmfaoo
meh that's fine
but if it was like if someshit: something(); someotherbullshit(); somehthingrandom(); i++; print(e)
lmfao
so beautiful π₯Ί
lmfao
btw could you theoretically compile any program into a 1 liner?
if it wasn't oop based
!e
def no_subclass(cls):
def __init_subclass__(subcls):
raise ValueError(f"{cls.__name__} Does not allow subclassing")
cls = type(cls.__name__, tuple(cls.__subclasses__()), {**cls.__dict__, '__init_subclass__': __init_subclass__})
return cls
@no_subclass
class A: ...
class B(A): ...
Done by @steep mural
@elfin onyx :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 10, in <module>
003 | File "<string>", line 3, in __init_subclass__
004 | ValueError: A Does not allow subclassing
I bet there's a lib for it, there are obfuscation libs, so that's probably something someone's done
ofc I would think there are limits
lark, for parsing
no I was just thinking there could be limits on how well the delimiters would keep the program from knowing what's what without needing different lines
unless you did that
lmafo
!e ```py
[(random:=import('random')),(input:=type("Input",(),{"init":lambda s:None,"call":lambda _,s:[print(s,end=''),print((c:=random.choice(['y','n']))),c][-1]})()),(i:='y'),{print((i:=input('y.n: '))) for _ in iter(lambda: i=='y',False)}]
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | y.n: y
002 | y
003 | y.n: n
004 | n
love it
that's one list object
!e ```py
print(
[(random:=import('random')),(input:=type("Input",(),{"init":lambda s:None,"call":lambda _,s:[print(s,end=''),print((c:=random.choice(['y','n']))),c][-1]})()),(i:='y'),{print((i:=input('y.n: '))) for _ in iter(lambda: i=='y',False)}]
)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | y.n: n
002 | n
003 | [<module 'random' from '/usr/local/lib/python3.9/random.py'>, <__main__.Input object at 0x7f017f53dfd0>, 'y', {None}]
and it has all the important things in it
k
!e ```py
print(
[[(input:=type("Input",(),{"init":lambda s:None,"call":lambda _,s:[print(s,end=''),print((c:=import('random').choice(['y','n']))),c][-1]})()),(i:='y'),{print((i:=input('y.n: '))) for _ in iter(lambda: i=='y',False)}] for j in range(42)]
)
lmfao very nice
random choice my foot
you see it always starts with 'n'
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | y.n: y
002 | y
003 | y.n: y
004 | y
005 | y.n: n
006 | n
007 | y.n: y
008 | y
009 | y.n: n
010 | n
011 | y.n: n
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/zorenozadi.txt
there's a y
!e ```py
print(
[(random:=import('random')),(input:=type("Input",(),{"init":lambda s:None,"call":lambda _,s:[print(s,end=''),print((c:=random.choice(['y','n']))),c][-1]})()),(i:='y'),{print((i:=input('y.n: '))) for _ in iter(lambda: i=='y',False)}][0].random()
)
!e
import random
a = {"y": 0, "z", 0}
for i in range(1000): a[random.choice(a)] += 1
print(a)```
@sick hound :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | a = {"y": 0, "z", 0}
003 | ^
004 | SyntaxError: invalid syntax
um
oops
!e
import random
a = {"y": 0, "n": 0}
for i in range(1000): a[random.choice(a.keys())] += 1
print(a)```
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | File "/usr/local/lib/python3.9/random.py", line 346, in choice
004 | return seq[self._randbelow(len(seq))]
005 | KeyError: 1
faq
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | y.n: y
002 | y
003 | y.n: y
004 | y
005 | y.n: y
006 | y
007 | y.n: y
008 | y
009 | y.n: n
010 | n
011 | 0.009768337441831698
there
!e
import random
a = {"y": 0, "n": 0}
for i in range(1000): a[random.choice(a.keys())] += 1
print(a)```
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | File "/usr/local/lib/python3.9/random.py", line 346, in choice
004 | return seq[self._randbelow(len(seq))]
005 | TypeError: 'dict_keys' object is not subscriptable
gtg bye
have fun, or else...
I WILL FIND YOU IF YOU DON"T HAVE FUN AHHAHAHAHA
jk
oh god oh fuck
parting challenge (you cant do this with bot):
yellow bars and floats are the time it takes to print the previous line.
one yellow bar for every 0.01 seconds printing random green text or spaces or 0s or 1s.
gotta be coloured. os.system("") and \x1b[32m should start you off \x1b[0m
gl
odds are, considering you'll almost exclusively have mangled headers
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
see for yourself
Seeing as I'm on Linux...
!e
!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
# Program make a simple calculator
# This function adds two numbers
def add(x, y):
return x + y
# This function subtracts two numbers
def subtract(x, y):
return x - y
# This function multiplies two numbers
def multiply(x, y):
return x * y
# This function divides two numbers
def divide(x, y):
return x / y
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
while True:
# Take input from the user
choice = input("Enter choice(1/2/3/4): ")
# Check if choice is one of the four options
if choice in ('1', '2', '3', '4'):
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
print(num1, "+", num2, "=", add(num1, num2))
elif choice == '2':
print(num1, "-", num2, "=", subtract(num1, num2))
elif choice == '3':
print(num1, "*", num2, "=", multiply(num1, num2))
elif choice == '4':
print(num1, "/", num2, "=", divide(num1, num2))
break
else:
print("Invalid Input")
@slim cairn :x: Your eval job has completed with return code 1.
001 | Select operation.
002 | 1.Add
003 | 2.Subtract
004 | 3.Multiply
005 | 4.Divide
006 | Enter choice(1/2/3/4): Traceback (most recent call last):
007 | File "<string>", line 28, in <module>
008 | EOFError: EOF when reading a line
Wrong channel (#bot-commands) and the bot doesn't support input @slim cairn
Ohk
please
Type your code here
def find_gcd(l):
num1=l[0]
num2=l[1]
for i in range(2,len(l)):
a=num1
b=num2
lista=[]
for i in range(3,11):
if (a%i==0) and (b%i==0):
lista.append(i)
acumulado=lista
if acumulado==[]:
return 1
else:
a=acumulado[-1]
return (acumulado[-1])
the error:
Your function return is NOT CORRECT.
For example when your function is called as shown below:
find_gcd([40, 80, 50])
Your function returns:
4
The correct return value is:
10
please, look at #βο½how-to-get-help
the topic Write a function named find_gcd that accepts a list of positive integers and returns their greatest common divisor (GCD). Your function should return 1 as the GCD if there are no common factors between the integers.
thaks
!e
# i just learned how to use walrus operator
print(_:=True.__int__())
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
1
!e ```py
print(:=True.int())
print(+1)
@naive roost :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
!e
print(_:=True.__int__())
print(_.__add__(_:=True.__int__()))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
yep, you get it. Now you can play with that in #bot-commands if you want to π
very cool
@sick hound :warning: Your eval job has completed with return code 0.
[No output]
memoryerror condensed into one line!
!e
print(_:=["_"], _:=[_.append(__*2)for __ in _])
@sudden willow :warning: Your eval job timed out or ran out of memory.
[No output]
How do I fix unused variable guild
remove the variable guild
Remove the word guild
if you're modifying the collection you're looping over, you deserve the bad things that might happen to you
???????
i was actually trying to figure out how to append it to the list and then pop it to create an infinite loop, but im lazy
@restive bronze you might want to see #βο½how-to-get-help to get better help
This is dumb
if you're not doing talking about esoteric Python, you might not want to talk here
if you want help, ask for help in the relevant help channels
like the subject says: Golfing, Python VM languages, obfuscation, code gore and other general Python weirdness
we were talking about that last night l o l
!e
print(_:=["_"], _:=[(_.append(__*2).pop(0))for __ in _])
.pop(0)
e
append returns None
!e
print(_:=["_"], _:=[(_.append(__*2), _.pop())for __ in _])
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
['_'] [(None, '__')]
Oh, you're using . to mean .
I used it to mean ,
int(twenty-seven-thousand. two-hundred and fifty-three) == 27253
!e
import string
_______ = [x for x in range(0,10)]
____,_____,______ = _______[1],_______[2],_______[3]
___________________,____________________________ = list(),[]
[____________________________.append(x) for x in eval('elbatnirp.gnirts'[::-1])]
[___________________.append(eval('elbatnirp.gnirts'[::-1])) for ______________ in ____________________________]
__=print
exec('def print(_):\n\tif(0.1+0.2 == 0.30000000000000004):\n\t\treturn(_)')
___ = [___________________[46][43],___________________[54][14], ___________________[29][34]]
_={194*0+5-4:___[0],5-______+_____-2:___[____],______-4+4*2/_____:___[2]}
def ________():
return _[____]+_[_____]+_[______+____-____]
__(________())
@sick hound :white_check_mark: Your eval job has completed with return code 0.
Hey
coolio
I think my favorite thing for version checking is
if 3 / 2 == 1:
input = raw_input
you might have wanted to say 3/2 == 1
so am I π
ooh
but yeah, it's interesting. probably more efficient than import sys; sys.version >= 3.0 or something
Not really, that involves importing the sys module
!e
print(_:=True.__int__().__add__(_:=True.__int__()))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
2
ah yes more letters to feed into my equation-inator
!e
print(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__().__add__(_:=True.__int__()))))))))))
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
10
!e
x = 1
print(x.add)
@plucky wedge :white_check_mark: Your eval job has completed with return code 0.
<method-wrapper '__add__' of int object at 0x7fa5cb657930>
x = 1 print(x.__add__(int))
oh
maybe instead of True.__int__() try __debug__.__bool__().__int__()
adds more dunders
hmm okay
interesting
heres the program i used to generate it btw
import sys
with open("writeoff.txt", "w") as f:
temp=int(sys.argv[1])-2
f.write("print(_:=__debug__.__bool__().__int__().__add__(")
for i in range(temp):
f.write("_:=__debug__.__bool__().__int__().__add__(")
f.write("_:=__debug__.__bool__().__int__()" + ")" * int(temp+2))
maybe instead of print you can do py ((lambda __, ___, ____, _____: getattr(__builtins__,().__class__.__name__[__ << __]+ ().__iter__().__class__.__name__[(__).__rmul__(-1)]+ [].__class__.__name__[____ % ___]+ chr(_____)+ ().__class__.__name__[__ >> __],))((lambda _: _).__code__.co_nlocals,(lambda _, __: _ | __).__code__.co_nlocals,(lambda _, __, ___: _ | __ | ___).__code__.co_nlocals,((lambda _, __, ___: _ & __ & ___).__code__.co_nlocals.__rmul__((lambda _, __, ___: _ | __ | ___).__code__.co_nlocals)+ (True.__rmul__((lambda _, __: _ | __).__code__.co_nlocals))).__rmul__((lambda _, __, ___, ____, _____, ______, _______, ________, _________, __________:_).__code__.co_nlocals),))
y
lol
wtf
What is this stuff you guys are always typing
simple python programs of course
very simple
Doesn't look simple
!e
print(__debug__)
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
True
kek
thats cool
why is _debug_ true?
not sure
but i guess you can convert __debug__ to True as a bool and then convert it to an int and return 1
debug is True because it runs the program unoptimized I think
hmm
ah so you're just abusing stuff
!e
try: a
except: print(__debug__)