#esoteric-python
1 messages · Page 112 of 1
Aren't they the same object?
not sure
>>> import sys
>>> sys.stdout is sys.__stdout__
True
decorator(lambda: ...)
you can't
Not with the @
Because @ is only for classes and functions
Oh that's what you meant
that's using a lambda as a decorator
!e
@lambda f: print(f.__name__, f())
def foo():
return "lol"
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
foo lol
As long as its callable and can take one argument
3.9
ty for corrections
!e
@print
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().set(a)))([]))
class a:...
@toxic jewel :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 "<string>", line 2, in <lambda>
004 | File "<string>", line 2, in <lambda>
005 | AttributeError: 'dict' object has no attribute 'set'
!e print(globals().dir())
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
['__repr__', '__hash__', '__getattribute__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__iter__', '__init__', '__or__', '__ror__', '__ior__', '__len__', '__getitem__', '__setitem__', '__delitem__', '__contains__', '__new__', '__sizeof__', 'get', 'setdefault', 'pop', 'popitem', 'keys', 'items', 'values', 'update', 'fromkeys', 'clear', 'copy', '__reversed__', '__class_getitem__', '__doc__', '__str__', '__setattr__', '__delattr__', '__reduce_ex__', '__reduce__', '__subclasshook__', '__init_subclass__', '__format__', '__dir__', '__class__']
it's a dict
isnt there a way to add to globals
!e
globals()['x'] = 'lol'
print(x)
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
lol
oh
!e
@print
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals()["test"]:=a))([]))
class a:...
@toxic jewel :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | @lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals()["test"]:=a))([]))
003 | ^
004 | SyntaxError: cannot use assignment expressions with subscript
globals().__setitem__('test', a)or a
why or a
I thought you wanted the value idk
I was doing the exact same thing globals()["test"]:=a would do but without the syntax error
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
([None], [<class '__main__.a'>])
!e
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().__setitem__('test',a)or a))([]))
@lambda*uwu:(globals().__setitem__('o', (globals().get('test').__str__()[1])))
class a:...
print(o)
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
o
it hurts
!e
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().__setitem__('test',a)or a))([]))
@lambda*uwu:(globals().__setitem__('o', (globals().get('test').__str__()[1])))
@lambda*uwu:(lambda a:(lambda v:(v.append(o)))((globals().__setitem__('_list', a)))([]))
class a:...
print(x for x in _list__)
@toxic jewel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | File "<string>", line 3, in <lambda>
004 | File "<string>", line 3, in <lambda>
005 | File "<string>", line 3, in <lambda>
006 | AttributeError: 'NoneType' object has no attribute 'append'
wtf is that function
i dont know anymore
i just want to print o
from a list
!e
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().__setitem__('test',a)or a))([]))
@lambda*uwu:(globals().__setitem__('o', (globals().get('test').__str__()[1])))
@lambda*uwu:(lambda a:(lambda v:(v.append(o)))((globals().__setitem__('_list', a)))([]))
class a:...
print(x for x in _list)
@toxic jewel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 6, in <module>
003 | NameError: name '_list' is not defined
!e
list1 = ['hi', 'hi', 'hi', 'hi', 'hi', 'hi', 'hi', 'hi']
print(i for i in list1)
@royal siren :white_check_mark: Your eval job has completed with return code 0.
<generator object <genexpr> at 0x7efd0001d6d0>
WTF
!e ```
print("you suck at eval")
@royal siren :white_check_mark: Your eval job has completed with return code 0.
you suck at eval
@royal siren :white_check_mark: Your eval job has completed with return code 0.
i am a bot and i suck at eval
each evaluation is in its own read-only file system sandbox, don't worry about breaking it
~e print(i for i in range(15))
~e print(i for i in range(15))
wtf wrong prefix aagh
!e print(i for i in range(15))
@royal siren :white_check_mark: Your eval job has completed with return code 0.
<generator object <genexpr> at 0x7faddeb496d0>
WTF
if you want to just play with the bot, please go to #bot-commands
!e
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().__setitem__('test',a)or a))([]))
@lambda*uwu:(globals().__setitem__('o', (globals().get('test').__str__()[1])))
@lambda*uwu:(lambda a:(lambda v:(v.append(o)))((globals().__setitem__('_list', a)))([])
class a:...
print(x for x in globals().get('_list'))
@toxic jewel :x: Your eval job has completed with return code 1.
001 | File "<string>", line 4
002 | class a:...
003 | ^
004 | SyntaxError: invalid syntax
!e
for i in range(15):
print("lol")
@royal siren :white_check_mark: Your eval job has completed with return code 0.
001 | lol
002 | lol
003 | lol
004 | lol
005 | lol
006 | lol
007 | lol
008 | lol
009 | lol
010 | lol
011 | lol
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/fokukavobu.txt?noredirect
lolololol
also, make sure you understand the decorator evaluation order before playing with those kinds of things
maybe clarify your decorators first, and make them esoteric after you've made them work
i just need to append o to a list inside a decorator but i guess im just bad now
my main goal was to have owo and then join them
to make esoteric code effectively, you really need to understand the underlying python evaluation 😅
@royal siren :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)>}
lol
too bad globals().get('variable') doesnt return the variable but just returns None
!e ```py
x = 5
print(globals()['x'])
@naive roost :white_check_mark: Your eval job has completed with return code 0.
5
oh yeah wait
globals() is just the dictionary of global variables, and, as for each dictionary, .get(value, default=None) returns default if value is not in the dictionary
!e
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().__setitem__('test',a)or a))([]))
@lambda*uwu:(globals().__setitem__('o', (globals().get('test').__str__()[1])))
@lambda*uwu:(lambda a:(lambda v:(v.append(o)))((globals().__setitem__('_list', a)))([]))
class a:...
print(x for x in globals()['_list'])
@toxic jewel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 6, in <module>
003 | KeyError: '_list'
@sick hound :white_check_mark: Your eval job has completed with return code 0.
3 + 90 = 93
there's also setdefault if you want to set a default value in your dictionary
!e py globals().setdefault('x', 5) print(x) globals().setdefault('x', 10) print(x)
@naive roost :white_check_mark: Your eval job has completed with return code 0.
001 | 5
002 | 5
might be useful
hm
!e
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().__setitem__('test',a)or a))([]))
@lambda*uwu:(globals().__setitem__('o', (globals().get('test').__str__()[1])))
@lambda*uwu:(lambda a:(lambda v:(v.append(o)))((globals().setdefault('_list', a)))([]))
class a:...
print(x for x in globals()['_list'])
@toxic jewel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 6, in <module>
003 | KeyError: '_list'
you might want to use globals().get, though, to not have a KeyError
hold on'
it will return None as a default if you don't specify it, though
!e
@lambda*uwu:((lambda a:([a.append(owo)for(owo)in(uwu)], globals().__setitem__('test',a)or a))([]))
@lambda*uwu:(globals().__setitem__('o', (globals().get('test').__str__()[1])))
@lambda*uwu:(lambda a:(lambda v:(v.append(o)))((globals().setdefault('_list', a)))([]))
@lambda*uwu:(print(_list))
class a:...
print(x for x in globals()['_list'])
@toxic jewel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | File "<string>", line 4, in <lambda>
004 | NameError: name '_list' is not defined
!e py print(globals().setdefault('x', 10))
@naive roost :white_check_mark: Your eval job has completed with return code 0.
10
codingis hard
!e py print(globals().__setitem__('x', 10))
@naive roost :white_check_mark: Your eval job has completed with return code 0.
None
right, that's partially what I was expecting
I started on a guide/wiki, but only got as far as whitespace.
!e
print(
globals().get(
(lambda x: return x)(globals().__setitem__('v',1))
))
@toxic jewel :x: Your eval job has completed with return code 1.
001 | File "<string>", line 3
002 | (lambda x: return x)(globals().__setitem__('v',1))
003 | ^
004 | SyntaxError: invalid syntax
eruhg
wait huh
!e
def↹function(*args,**kwargs):
↹↹↹↹return↹*args,**kwargs
function("lol")
@toxic jewel :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | def↹function(*args,**kwargs):
003 | ^
004 | SyntaxError: invalid character '↹' (U+21B9)
i have never felt more lied to
You were meant to use actual tabs, not the placeholders.
This works if you get rid on the final indent and the return in the lambda.
Lambdas implicitly return.
!e
@lambda*v:...
class v:...
@toxic jewel :warning: Your eval job has completed with return code 0.
[No output]
replit just must not like me\
It's probably using Python 3.8.
the restricted syntax on decorators was relaxed with Python 3.9
You can do ```python
identity = lambda x: x
@identity(lambda v:...)
class v:...
The identity function does nothing, but the syntax likes it because it has a name.
also, your previous code is weird, because globals()[None] is a KeyError
Where does it index globals with None?
globals().__setitem__('v',1) returns None
globals().get returns None if the key isn't found.
You know you can also do .update({'_list':a}) if setitem is too painful XD
Or to set multiple values
Alright I'm on phone but I will try to make python code that does exactly what it does when evaluated in brainfuck
Prepare to suffer from PTSD
Ah well I accidentally backspaced and phone got no ctrlz
I'm gonna plug my laptop in
derp here we go. So I'm gonna try to emulate the following:
[-][python init here]
++++++++++
[
>+++++
<-
][,,,,,,,,,,,,,,,,,,,,XD]
>++.
--.--.
!e ```py
#[-][
@lambda :()
class :
input,en_in="",True
B=2<<2
def init(s):
s.i=s.o=2>>2
s.a=[s.i]*((2<<s.o)s.B)
def pos(s):
s.o += 1
return s
def neg(s):
s.o -= 1
return s
def add(s,o):
s.a[s.i] += +(s.o,setattr(s,'o',0))[0]+ 1
s.a[s.i] %= 2s.B
return s
def sub(s,o):
s.o =- +s.o+ 1
s.a[s.i] -= (s.o,setattr(s,'o',0))[False]
s.a[s.i] %= 2**s.B
return s
def getattr(s,a):
try:return object.getattr(s,a)
except:return print(end=chr(s.a[s.i]))or s
def getitem(s,f):
if type(f)==type(lambda:None):
while s.a[s.i]:f()
elif f is s:
if s.o:s.a[s.i]=s.o=0
elif s.a[s.i]:raise RecursionError
elif type(f)is tuple:s(f)
elif f is...:s . ._ ._
return s
def gt(s,o):
s.i += 1
s.a.extend([0]* (s.i- +len(s.a)+ 1))
return s
def lt(s,o):
if s.i:s.i -= 1
else:s.a.insert(0,0)
return s
def rshift(s,o):
s>o
return s>o
def lshift(s,o):
s<o
return s<o
def call(s,*a):
s.a[s.i]=ord(s.input and [s.input.pop(False)for i in range( +len(a)+ -True)][-True]or '\0'if s.en_in else import('sys').stdin.read( +len(a)+ -True)[-True])
return s
#] I think I covered all the bases
([-][]++++++++++)[
lambda:((>)+++++ <)-_
]>;(((++).--).--).
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
420
I MADE THE BOT EVALUATE STRAIGHT BRAINFUCK MWAHAHAHAHAHAHAHA
can someone help me with this simple coding pls?
eval ?
!e ```py
#[-][
@lambda :()
class :
input,en_in="",True
B=2<<2
def init(s):
s.i=s.o=2>>2
s.a=[s.i]*((2<<s.o)s.B)
def pos(s):
s.o += 1
return s
def neg(s):
s.o -= 1
return s
def add(s,o):
s.a[s.i] += +(s.o,setattr(s,'o',0))[0]+ 1
s.a[s.i] %= 2s.B
return s
def sub(s,o):
s.o =- +s.o+ 1
s.a[s.i] -= (s.o,setattr(s,'o',0))[False]
s.a[s.i] %= 2**s.B
return s
def getattr(s,a):
try:return object.getattr(s,a)
except:return print(end=chr(s.a[s.i]))or s
def getitem(s,f):
if type(f)==type(lambda:None):
while s.a[s.i]:f()
elif f is s:
if s.o:s.a[s.i]=s.o=0
elif s.a[s.i]:raise RecursionError
elif type(f)is tuple:s(f)
elif f is...:s . ._ ._
return s
def gt(s,o):
s.i += 1
s.a.extend([0]* (s.i- +len(s.a)+ 1))
return s
def lt(s,o):
if s.i:s.i -= 1
else:s.a.insert(0,0)
return s
def rshift(s,o):
s>o
return s>o
def lshift(s,o):
s<o
return s<o
def call(s,*a):
s.a[s.i]=ord(s.input and [s.input.pop(False)for i in range( +len(a)+ -True)][-True]or '\0'if s.en_in else import('sys').stdin.read( +len(a)+ -True)[-True])
return s
#] I think I covered all the bases
(++++++++++)[
lambda:(((((>)++++++++++)>)+++++++++++>)+++<<<)-
]>_
(>>)++_
<<
(++++).---
.>_
(--)..
(+++).>
(.<)++++++++
(.--------).+++_
(.<)+++++++
.--------_
(.>>)+
.
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
hello world!
!e
def decor(func):
def outer_wrapper():
def inner_wrapper():
def super_inner_wrapper():
def ultra_inner_wrapper():
def extreme_advanced_wrapper():
def final_level_wrapper_executor():
def super_final_level_wrapper_executor():
print('wrapper executed')
func()
return super_final_level_wrapper_executor
return final_level_wrapper_executor()
return extreme_advanced_wrapper()
return ultra_inner_wrapper()
return super_inner_wrapper()
return inner_wrapper()
return outer_wrapper()
@decor
def hello():
extra_decor()
@decor
def extra_decor():
hello()
@decor
def extra_extra_decor():
hello()
@decor foo():
extra_extra_decor()
foo()
@hollow kiln :x: Your eval job has completed with return code 1.
001 | File "<string>", line 27
002 | @decor foo():
003 | ^
004 | SyntaxError: invalid syntax
👀 damg
!e
def decor(func):
def outer_wrapper():
def inner_wrapper():
def super_inner_wrapper():
def ultra_inner_wrapper():
def extreme_advanced_wrapper():
def final_level_wrapper_executor():
def super_final_level_wrapper_executor():
print('wrapper executed')
func()
return super_final_level_wrapper_executor
return final_level_wrapper_executor()
return extreme_advanced_wrapper()
return ultra_inner_wrapper()
return super_inner_wrapper()
return inner_wrapper()
return outer_wrapper()
@decor
def hello():
extra_decor()
@decor
def extra_decor():
hello()
@decor
def extra_extra_decor():
hello()
@decor
foo():
extra_extra_decor()
foo()
@hollow kiln :x: Your eval job has completed with return code 1.
001 | File "<string>", line 28
002 | foo():
003 | ^
004 | SyntaxError: invalid syntax
ahhhahHSH
!e
def decor(func):
def outer_wrapper():
def inner_wrapper():
def super_inner_wrapper():
def ultra_inner_wrapper():
def extreme_advanced_wrapper():
def final_level_wrapper_executor():
def super_final_level_wrapper_executor():
print('wrapper executed')
func()
return super_final_level_wrapper_executor
return final_level_wrapper_executor()
return extreme_advanced_wrapper()
return ultra_inner_wrapper()
return super_inner_wrapper()
return inner_wrapper()
return outer_wrapper()
@decor
def hello():
extra_decor()
@decor
def extra_decor():
hello()
@decor
def extra_extra_decor():
hello()
@decor
def foo():
extra_extra_decor()
foo()
@hollow kiln :x: Your eval job has completed with return code 1.
001 | wrapper executed
002 | wrapper executed
003 | wrapper executed
004 | wrapper executed
005 | wrapper executed
006 | wrapper executed
007 | wrapper executed
008 | wrapper executed
009 | wrapper executed
010 | wrapper executed
011 | wrapper executed
... (truncated - too many lines)
Full output: too long to upload
Stop
Can someone help me with an exam
Try #❓|how-to-get-help.
of course whats the first question
im aware im planning on answering the questions as esoterically as possible
!e
@lambda*u: v := lambda: print('hi')
@v()
class a:...
@sudden willow :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | @lambda*u: v := lambda: print('hi')
003 | ^
004 | SyntaxError: cannot use assignment expressions with lambda
interesting
!e
@lambda *u: globals().__setitem__('v', lambda: print('hi'))
@lambda *u: globals().get('v')
class a:...
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
@sudden willow think about the order that decorators are ran
yea
you get set_v(v(cls))
no v is getting called before set_v
wait you're right
!e py @v @lambda c:globals().__setitem__('v', lambda f:print('hi')) class a:pass
@rugged sparrow :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'v' is not defined
hmm
!e
@lambda c:globals()['v']()
@lambda c:globals().__setitem__('v', lambda f:print('hi'))
class a:pass
!e ```py
def set_v(f):
global v
v = lambda f:print('hi')
@v
@set_v
class c:pass```
@rugged sparrow :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | NameError: name 'v' is not defined
hmm
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
this doesnt call v
Python first loads v and set_v respectively and then calls them
from the reverse order
oh it loads them both before calling
yep
ah
interesting
ooh i can use decorator syntax to put things on the c vm stack
this is good for linear evaluation (so that we don't have to push/pop stuff)
!e
@lambda c:globals()['v']('a')
@lambda c:globals().__setitem__('v', lambda f:print('hi'))
class a:pass
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
hi
2 0 LOAD_CONST 0 (1)
3 2 LOAD_CONST 1 (2)
4 4 LOAD_CONST 2 (3)
5 6 LOAD_BUILD_CLASS
8 LOAD_CONST 3 (<code object a at 0x7f88b9b6b710>)
10 LOAD_CONST 4 ('a')
12 MAKE_FUNCTION 0
14 LOAD_CONST 4 ('a')
16 CALL_FUNCTION 2 <-- my metaclass is ran here
18 CALL_FUNCTION 1
20 CALL_FUNCTION 1
22 CALL_FUNCTION 1``` i could totally use this to pull those items off the stack with a meta class
not too sure what that is but looks cool!
its the dis of py @1 @2 @3 class a:pass
nice
wait hold on
!e
@lambda v: print(3)
@lambda v: print(2)
@lambda v: print(1)
class v:...
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | 3
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
<function femboys at 0x7fbc25123940>
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | TypeError: 'tuple' object is not callable
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
<class '__main__.v'>
!e
@lambda f : (f, 1)
def test():
pass
print(test.__class__())
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
()
you're making the function a tuple
print is NoneType
because print returns none
!e
print(print())
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | None
i'm not sure what you're trying to achieve
!e ```py
@print
@print
def foo():()
@snow beacon :white_check_mark: Your eval job has completed with return code 0.
001 | <function foo at 0x7f7ff2efa040>
002 | None
basically, what you have is foo = print(print(foo)), with the first print returning None
!e ```py
from ctypes import *
import sys
import dis
pythonapi.Py_IncRef.argtypes=[py_object]
class Singleton(type):
def new(self, name, bases, body):
frame = sys._getframe(1)
segment = frame.f_code.co_code[frame.f_lasti + 2:]
num_decos = 0
for op, arg in zip(segment[::2], segment[1::2]):
if op == dis.opmap['CALL_FUNCTION'] and arg == 1:
num_decos += 1
else:
break
stacktop = POINTER(py_object).from_address(id(frame) + sizeof(c_void_p) * 8)
args = stacktop[:num_decos]
for idx in range(num_decos):
f = lambda c:c
pythonapi.Py_IncRef(f)
stacktop[idx] = f
cls = super().new(self.base, name, bases, body)
return cls(*args)
@1
@2
@(1,2,3)
class instance(metaclass=Singleton):
def init(self, *initial_values):
print('instance initialized with', *initial_values)
self.args = initial_values
def __repr__(self):
return f'instance{self.args}'
print(instance)```
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
001 | instance initialized with 1 2 (1, 2, 3)
002 | instance(1, 2, (1, 2, 3))
interesting
@sudden willow :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | >w<
003 | ^
004 | SyntaxError: invalid syntax
is there a dunder for the ^ operator?
__xor__
@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 | TypeError: '' object is not callable
@sudden willow :warning: Your eval job has completed with return code 0.
[No output]
i come here for my biweekly dose of insanity. i've seen enough today
!e lambda lambda: lambda
@toxic jewel :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | lambda lambda: lambda
003 | ^
004 | SyntaxError: invalid syntax
fixed the character readability issue so now its not just hi
!e
@lambda c:globals()['v']((chr(111),chr(119),chr(111)))
@lambda c:globals().__setitem__('v', lambda v:print(''.join(c for c in v)))
class c:pass
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
owo
wait
!e
@lambda c:globals()['v']([104, 105])
@lambda c:globals().__setitem__('v', lambda v:print(''.join(chr(c) for c in v)))
class c:pass
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
hi
nice
wait
!e
@lambda c:globals()['v'](104 | 105)
@lambda c:globals().__setitem__('v', lambda *v:print(''.join(chr(c) for c in *v)))
class c:pass
@sudden willow :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | @lambda c:globals().__setitem__('v', lambda *v:print(''.join(chr(c) for c in *v)))
003 | ^
004 | SyntaxError: invalid syntax
hmm
!e
@lambda c:globals()['v'](104, 105)
@lambda c:globals().__setitem__('v', lambda *v:print(''.join(chr(c) for c in *v))))
class c:pass
@sudden willow :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | @lambda c:globals().__setitem__('v', lambda *v:print(''.join(chr(c) for c in *v))))
003 | ^
004 | SyntaxError: invalid syntax
Why *v
But why are you unpacking it
wouldnt it return like a list/tuple else
(x for x in *y)
Is invalid syntax
(x for x in y)
Is valid syntax
oh yeah wait
!e
@lambda c:globals()['v']((104 & 105))
@lambda c:globals().__setitem__('v', lambda *v:print(''.join(chr(c) for c in v)))
class c:pass
nice
lmao
Lol
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
h
!e
print(104 | 105, 104 & 105)
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
105 104
so i assume | chooses the highest/truthiest value and & chooses first
@sick hound :white_check_mark: Your eval job has completed with return code 0.
104 105
or returns the first true value (or false if no true values)
and returns the last value (or false if any are false)
that's why you can do stuff like
def fibonacci(n):
return [
((i==n-1 and (x:=(x[i-1] + x[i-2]))) \
or (i==0 and (x:=[1,1])) \
or x.append(x[i] + x[i-1])) \
if n>2 else (x:=1)\
for i in range(0,n)] \
and x
is_even = lambda i: i & (420 | 69) & ((i ^ (i+1)) & ((i << 1)^((i << 2) | 3) & 3)) == 1 & 2 | 3 & 4 | 7 & 8
!e (1<<198,)*47
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | MemoryError
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | MemoryError
!e (lamda a,b,c:print(a);print(b);print(c);)(1,2,3)
@sick hound :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | (lamda a,b,c:print(a);print(b);print(c);)(1,2,3)
003 | ^
004 | SyntaxError: invalid syntax
!e lambda t:print("sex");a=true;print(a && t())
@sick hound :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | lambda t:print("sex");a=true;print(a && t())
003 | ^
004 | SyntaxError: invalid syntax
!e lambda t:print("sex");a=true;print(a and t())
@sick hound :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 'true' is not defined
!e lambda t:print("sex");a=True;a and t()
@sick hound :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 't' is not defined
!e t=lambda:print("sex");a=True;a and t()
@sick hound :white_check_mark: Your eval job has completed with return code 0.
sex
whats the weirdest way to do an if statement
what I did
"a and t()"
if a is true run the t function
ok bet
exec("t()"*bool(a))
brilliant
a and t() i usually prefer over the if statement.
Why?
r = a and t() and 4 or 2
instead of
r=2
if a:
if t():
r=4
now behold as i brainfuck in python
(code if condition)
(code if condition else ...) # to prevent syntax error
yea
That isn't true xd
this code does exactly the same thing in both a python and brainfuck interpeters
what is the underscore?
it's a massive class full of dunders in order to make python interpret it.
underscores are ignored by brainfuck
oh
hence allowing them and curved parenthesis, and pretty much any non-brainfuck character to be used to make the script compatible with python
#[-][
@lambda _:_()
class _:
input,en_in="",True
B=2<<2
__eq__,__ne__=lambda s,o:s,lambda s,o:[setattr(s,'input',o),setattr(s,'en_in',True)]if o is not None else[setattr(s,'input',""),s9etattr(s,'en_in',False)]
__bool__=lambda s:()==()
__int__=lambda s:s.a[s.i]
__str__=lambda s:chr(int(s))
__repr__=lambda s:f"\n<{s.i}: {int(s)}>"
def __init__(s):
s.i=s.o=2>>2
s.a=[s.i] *((2<<s.o)**s.B* 1)
def __pos__(s):
s.o += 1
return s
def __neg__(s):
s.o -= 1
return s
def __add__(s,o):
s.a[s.i] += +(s.o,setattr(s,'o',0))[0]+ 1
s.a[s.i] %= 2**s.B
return s
def __sub__(s,o):
s.o =- +s.o+ 1
s.a[s.i] -= (s.o,setattr(s,'o',0))[False]
s.a[s.i] %= 2**s.B
return s
def __getattr__(s,a):
try:return object.__getattr__(s,a)
except:return print(end=str(s))or s
def __getitem__(s,f):
if type(f)==type(lambda:None):
while int(s):f()
elif f is s:
if s.o:s.a[s.i]=s.o=0
elif int(s):raise RecursionError
elif type(f)is tuple:s(f)
return s
def __gt__(s,o):
s.i += 1
s.a.extend([0]* (s.i- +len(s.a)+ 1))
return s
def __lt__(s,o):
if s.i:s.i -= 1
else:s.a.insert(0,0)
return s
def __rshift__(s,o):
s>o
return s>o
def __lshift__(s,o):
s<o
return s<o
def __call__(s,*a):
if len(a)>1:s.a[s.i]=ord(s.input and[s.input.pop(False)for i in range( +len(a)+ -True)][-True]or '\0'if s.en_in else __import__('sys').stdin.read( +len(a)+ -True)[-True])
elif a is...:(print(s),print(s),print(s),)
return s
#] I think I covered all the bases
lmaoo so cursed
how
it just is lol
they are just weird
wdym
i would love to know what esoteric is to you
what it does is esoteric
you want me to make a rust syntax rip-off in python?
yes
show me some rust code
ok
a brainfuck interpreter in rust
!e py(lambda:print("\n".join(["linux term" for i in range(50)])))()
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'py' is not defined
oops
I'm not making a whole flash player
oh you want to actually replicate lol
!e py (lambda:print("\n".join(["linux term" for i in range(50)])))()
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | linux term
002 | linux term
003 | linux term
004 | linux term
005 | linux term
006 | linux term
007 | linux term
008 | linux term
009 | linux term
010 | linux term
011 | linux term
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/erizeyamew.txt?noredirect
here ig?
just searched on github
I'm not gonna make the entire rust interpreter either
this is not python 😡
neither is python
get your golang out of here
idk
you can't really do
f a b{whatever;}
in python :/
if only yoct was here and javascript was allowed
just do println!
I was just making a joke on how rust keywords are unreadable
i wanna see how tou use ! in python variables
not operator
use std::io::{self, prelude::*};
unfortunately, this will raise a SyntaxError, and no code can run precompiled
SyntaxError
!e print("a") if not False
@sick hound :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print("a") if not False
003 | ^
004 | SyntaxError: invalid syntax
stupid
thought you could do that
told you
!e
print("a") if not False else ...
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
a
smh
also -> will raise syntax error in python so i'd have to find a rip-off of that syntax
what mikelime
what
what
it's to access members of a class
no
!e ```py
a = True
(a and(lambda e:e())or(lambda*e:None))(lambda:print(420))
I don't use python much lol
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
420
69
!e
@lambda c:globals()['v'](104, 105)
@lambda c:globals().__setitem__('v', lambda *v:print(''.join(chr(c) for c in v)))
class c:pass
@floral meteor are you proud dad
@toxic jewel :white_check_mark: Your eval job has completed with return code 0.
hi
just ignore that
!e ```py
def split(a):
return a.divmod(10)
def left_bias(t):
return t[0]*10,t[1]-2
def rejoin(t):
return int.mul(*t)
@print
@rejoin
@left_bias
@split
@int
@lambda c:c()
class n:int=lambda _:69
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
420
YOU WANTED 69 420 YOU GOT 69 420
bruuu
!e
@print
@print()
class c:...
@toxic jewel :x: Your eval job has completed with return code 1.
001 |
002 | Traceback (most recent call last):
003 | File "<string>", line 3, in <module>
004 | TypeError: 'NoneType' object is not callable
sadge
someone I know does stuff like this in javascript
we aren't doing javascript
I know
j*vascript

question mark symbol straight up does not exist in pytho
no ternary operator 😭
python can't compete
slightly irrelevant but this is a great article about the optimization branchless programming can have https://dev.to/jobinrjohnson/branchless-programming-does-it-really-matter-20j4
JS is banned in here 😭
I mean...python is in the name
That won't stop me from weeping 😭
@lambda c:c()
class use:
def __getattr__(s,package):
r=globals()[package]=__import__(package)
return r
@lambda c:use.sys.modules.__setitem__('std',c())
class std:
class io:
__eq__=lambda s,a:return[getattr(s,e) for e in a]
def self(s,n):
c=__import__('sys')._getframe(n+1).f_code
f=lambda:None
f.__code__=c
return f
def prelude(s,*a):pass # TODO: prelude
class env:pass #TODO: env
class fs:
def __eq__(s,name):
globals()[name]=getattr(s,name)()
return globals()[name]
@lambda c:c()
class File:... # TODO: File module
def __eq__(self, name):
globals()[name]=getattr(self,name)()
return globals()[name]
@lambda c:use.sys.modules.__setitem__('brainfuck',c())
class bf:pass # TODO: brainfuck.js
@lambda c:c()
class fn:
def __getattr__(s,n):
def outer(*a,**k):
def wrapper(f):
def inner(*args,**kwargs):
if len(args)>len(a) or len(k|kwargs)>len(k|{e:None for e in a}):
raise Exception("Args do not match")
k|=kwargs
return f(*args,**k)
return inner
return wrapper
outer.__name__=n
globals[n]=outer
return outer
hang on gotta take a breather

use.std==io=={"self","prelude::*"};
use.std.env;
use.std.fs.File;
bf = use.brainfuck;
@fn.read_file("filename")
def read_file(filename: str) -> (Result<String, io==Error,):
let.mut.contents = String==new();
with File==open(filename) as _:
_.read_to_string(mut.contents);
return Ok(contents);
@fn.main()
def main():
let.args = env==args().collect();
let.filename = match.args.get(1)=={Some:lambda s:Some(s), None:lambda s:panic!=("missing filename")};
let.contents = read_file(filename).expect("Error reading file");
let.token = bf==tokenize(contents.chars().collect());
let.expressions = bf==parse(tokens).expect("Error compiling program");
let.expressions = bf==optimize(expressions);
bf==run(expressions).expect("Error running program");
is the best i can do
js cring
In my experience, it's like running freely through a forest, until the trees end and you fall into a ravine.
@snow beacon can i contribute to the wiki?
By all means. I don't have the time to work on it at the moment, so people helping is the only way it'll get finished in a timely fashion.
I can credit you if you want.
I'm not sure if GitHub lets you do pull requests for wiki pages, so if anyone makes something, ping me.
have you done much more than the whitespace page yet?
where is the link to it?
what does @ do in py
Decorators
A decorator is a function that modifies another function.
Consider the following example of a timer decorator:
>>> import time
>>> def timer(f):
... def inner(*args, **kwargs):
... start = time.time()
... result = f(*args, **kwargs)
... print('Time elapsed:', time.time() - start)
... return result
... return inner
...
>>> @timer
... def slow(delay=1):
... time.sleep(delay)
... return 'Finished!'
...
>>> print(slow())
Time elapsed: 1.0011568069458008
Finished!
>>> print(slow(3))
Time elapsed: 3.000307321548462
Finished!
More information:
• Corey Schafer's video on decorators
• Real python article
@sick hound ^
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
__abs__ __add__ __and__ __bool__ __ceil__ __class__ __delattr__ __dir__ __divmod__ __doc__ __eq__ __float__ __floor__ __floordiv__ __format__ __ge__ __getattribute__ __getnewargs__ __gt__ __hash__ __index__ __init__ __init_subclass__ __int__ __invert__ __le__ __lshift__ __lt__ __mod__ __mul__ __ne__ __neg__ __new__ __or__ __pos__ __pow__ __radd__ __rand__ __rdivmod__ __reduce__ __reduce_ex__ __repr__ __rfloordiv__ __rlshift__ __rmod__ __rmul__ __ror__ __round__ __rpow__ __rrshift__ __rshift__ __rsub__ __rtruediv__ __rxor__ __setattr__ __sizeof__ __str__ __sub__ __subclasshook__ __truediv__ __trunc__ __xor__ as_integer_ratio bit_length conjugate denominator from_bytes imag numerator real to_bytes
hmmm
(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 _, __, ___, ____, _____, ______, _______, ________: _
)
)
)
can someone explain
how this prints "Hello World!"
ah yes thanks for detailed explanation
np
aight ```py
(
lambda _: _,
lambda _, __: _,
lambda _, __, ___: _,
lambda _, __, ___, ____: _,
lambda _, __, ___, ____, _____: _,
lambda _, __, ___, ____, _____, ______: _,
lambda _, __, ___, ____, _____, ______, _______: _,
lambda _, __, ___, ____, _____, ______, _______, ________: _
)
is a tuple of lambdas, `lambda _: _.__code__.co_argcount` converts one of the above into an integer, 1-8
`[__(___[(lambda: _).__code__.co_nlocals])]` is `[__(___[1])]`
and so on
it's just obfuscated, that's all
and the rest calls a secret brainfuck interpreter built into python
Nope.
Oh, I've been preempted.
Because ! is not a valid Python operator.
You might be thinking of ~ or not.
Not really.
It's from inverting all the bits in a two's-complement integer.
not is an operator.
There is not one, unless you store your Boolean true as -1.
python doesnt have multiline lambda
#[-][ challenge: rewrite this...
@lambda _:_()
class _:
input,en_in="",True
B=2<<2
__eq__,__ne__=lambda s,o:s,lambda s,o:[setattr(s,'input',o),setattr(s,'en_in',True)]if o is not None else[setattr(s,'input',""),s9etattr(s,'en_in',False)]
__bool__=lambda s:()==()
__int__=lambda s:s.a[s.i]
__str__=lambda s:chr(int(s))
__repr__=lambda s:f"\n<{s.i}: {int(s)}>"
def __init__(s):
s.i=s.o=2>>2
s.a=[s.i] *((2<<s.o)**s.B* 1)
def __pos__(s):
s.o += 1
return s
def __neg__(s):
s.o -= 1
return s
def __add__(s,o):
s.a[s.i] += +(s.o,setattr(s,'o',0))[0]+ 1
s.a[s.i] %= 2**s.B
return s
def __sub__(s,o):
s.o =- +s.o+ 1
s.a[s.i] -= (s.o,setattr(s,'o',0))[False]
s.a[s.i] %= 2**s.B
return s
def __getattr__(s,a):
try:return object.__getattr__(s,a)
except:return print(end=str(s))or s
def __getitem__(s,f):
if type(f)==type(lambda:None):
while int(s):f()
elif f is s:
if s.o:s.a[s.i]=s.o=0
elif int(s):raise RecursionError
elif type(f)is tuple:s(f)
return s
def __gt__(s,o):
s.i += 1
s.a.extend([0]* (s.i- +len(s.a)+ 1))
return s
def __lt__(s,o):
if s.i:s.i -= 1
else:s.a.insert(0,0)
return s
def __rshift__(s,o):
s>o
return s>o
def __lshift__(s,o):
s<o
return s<o
def __call__(s,*a):
if len(a)>1:s.a[s.i]=ord(s.input and[s.input.pop(False)for i in range( +len(a)+ -True)][-True]or '\0'if s.en_in else __import__('sys').stdin.read( +len(a)+ -True)[-True])
elif a is...:(print(s),print(s),print(s),)
return s
# ][... but without these commented brackety things...
# but when evaluated in brainfuck, it ends in the same state it started in. ]
!e ```py
print (
(
lambda _, __:
10 * _ .mul (
__ - 2
),
)[
0
](
*(
lambda _:
_.divmod(
10
)
)(
69
)
)
)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
420
That's an awful lot of templates.
they are still single expression tho (with a lot of expressions inside that single expression)
im gonna try to make true multiline lambdas
im still figuring that out lol
easy, just make your own namespaaaaaaaace
or even...
(lambda a, b, c:None).__code__ += (lambda:a+b+c).__code__
i think what i want would require hooking into the compiler :/
i no coffe suficient
You could probably edit FunctionType.
It contains the code object for a function. Bytecode, variable names etc.
!e ```py
class MLl:
def init(self, f):
self.f=f
def call(self,*a,**k):
return self.f(*a,**k)
def add_line(self, f):
self.f.code = self.f.code.replace(co_code=self.f.code.co_code + f.code.co_code)
return self
multi_line_lambda = MLl(lambda a, b, c:None)
multi_line_lambda.add_line(lambda a,b:a+b)
multi_line_lambda.add_line(lambda _, b, c:b+c)
print(multi_line_lambda(1,2,3))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
None
@rugged sparrow the problem is the first line returns
thats not the only issue there
!e ```py
def fff(a, b, c):
print(globals()['kkk'].code.co_code)
return globals()['kkk'](b, a, c)
kkk=lambda*a:print(fff.code.co_code)or a
print(fff(2, 3, 4))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | b't\x00t\x01j\x02j\x03\x83\x01p\x0e|\x00S\x00'
002 | b't\x00t\x01\x83\x00d\x01\x19\x00j\x02j\x03\x83\x01\x01\x00t\x01\x83\x00d\x01\x19\x00|\x01|\x00|\x02\x83\x03S\x00'
003 | (3, 2, 4)
wait i should made them the same
!e ```py
def fff(*a): print(a)
f=lambdaa:print(*a)
print(fff.code.co_code, f.code.co_code)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
b't\x00|\x00\x8e\x00\x01\x00d\x00S\x00' b't\x00|\x00\x8e\x00S\x00'
!e ```py
def fff(*a):return print(a)
f=lambdaa:print(*a)
print(fff.code.co_code, f.code.co_code)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
b't\x00|\x00\x8e\x00S\x00' b't\x00|\x00\x8e\x00S\x00'
oh, the def additionally LOAD_CONST 0
unless returned from
dafuq you can optimise by making it return
b't\x00|\x00\x8e\x00S\x00'
b't\x00|\x00\x8e\x00S\x00'
``` those are identical
ye but the one above that i didn't return from the function
!e ```py
def ():pass
print(.code.co_code)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
b'd\x00S\x00'
ah so that loads and returns None
the arg for RETURN_VALUE is unused
so what if we hacked that to "add" a function?
you could but youd need to add some other stuff to the code objects
test if it loads and returns None, and if so, wipe the S\00 of the first function and concatenate the code
and make sure the constants are in the same order
hm
!e ```py
class MLl:
def init(self, f):
self.f=f
def call(self,*a,**k):
return self.f(*a,**k)
def add_line(self, f):
self.f.code = self.f.code.replace(co_code=self.f.code.co_code.replace(b'S\0',b'') + f.code.co_code)
return self
multi_line_lambda = MLl(lambda a, b, c:print ("lol"))
multi_line_lambda.add_line(lambda e, f, g:e+f+g)
print(multi_line_lambda(1,2,3))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | lol
002 | 6
i mean that works
it works tho
except, problem is the next line cannot reference the result of the previous line
without hacking the code a bit more directly
hmm
how do i join their locals?
that is much trickier
okay, how do i make the first line add something to some stack that could then be accessed by a later line?
it would be easier to do this with globals hooking and wrapping the functions
class MLl:
def __init__(self, f):
self.f=f
def __call__(self,*a,**k):
return self.f(*a,**k)
__bool__ = lambda s:True
def add_line(self, f):
self.f.__code__ = self.f.__code__.replace(co_code=self.f.__code__.co_code.replace(b'S\0',b'') + f.__code__.co_code)
return self
def add_if(self,cond,f,g):
return cond and self.add_line(f) or self.add_line(g)
def add_while(self, f, cf):
def inner(*a,**k):
while cf():
f(*a,**k)
return self.add_line(inner)
def add_for(a, f):
def inner(*a,**k):
for i in a:
f(i,*a,**k
return self.add_line(inner)
def add_try(f, E, g):
def inner(*a,**k):
try:return f(None,*a,**k)
except E as e:return f(e,*a,**k)
return self.add_line(inner)
alright how do i try except from a lambda?
It's a literal, kind of like how None is a NoneType literal.
You can define a function whose body is foo(), 0 or None, or indeed ....
I prefer to use it infinite loops:
while ...:
print("y")
Why is type(...) ellipsis, but when you do type(...)(1) you get the error TypeError: EllipsisType takes no arguments, i.e. why EllipsisType and ellipsis, whereas type(None) is NoneType and that is consistent with the error
!e ```py
print(type(...))
print(type(None))
@naive roost :white_check_mark: Your eval job has completed with return code 0.
001 | <class 'ellipsis'>
002 | <class 'NoneType'>
How would I tackle making this smaller?
class Solution:
def singleNumber(self, n: List[int]) -> int:
return [k for k,v in __import__('collections').Counter(n).items() if v==1][0]```
should I try to prevent using a counter?
in space or time complexity?
time complexity, my bad
Getting the space complexity down is going to be hard on one line
import collections;collections.Counter(nums).most_common()[-1][0] works I think?
Isnt _import_ prefered over that?
oh ye not sure why I forgot about that
class Solution:singleNumber=lambda s,n:__import__('collections').Counter(n).most_common()[-1][0]
``` works
thanks.
from collections import*;Counter(nums).most_common()[-1][0]
__import__("collections").Counter(nums).most_common()[-1][0]
I found time to make a draft of part 2 of the guide, if you want to get ahead on your esoteric education: https://github.com/IFcoltransG/esoteric-python-guide/wiki/2:-Truthiness-and-Falsiness-[Under-Construction]
It's a bit more of an information dump than the one before, but time is esoteric.
Nice, thanks for the resource
excited to see when lambda is released
@snow beacon i dont think we can make pull requests, would you mind if i PM you stuff i write for it?
!e
a='b'
@lambda c: print(a)
@lambda c: globals().__setitem__('a', 'c')
class v:...
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
c
@sudden willow :white_check_mark: Your eval job has completed with return code 0.
i love femboys x3
x3
@sudden willow :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 "<string>", line 1, in <lambda>
004 | TypeError: 'owo' object is not callable
Please do.
would you like help writing that up?
If so, how would i be able to?
I didn't have any ideas for more content in the Truthiness and Falsiness section, I was just going to tidy it and add some dry wit.
The plan for other sections is in the sidebar — you could work on one of them or a different topic.
!e ```py
@lambda c:globals()['cout']<<"[REDACTED]"
@lambda c:globals().update({'cout':c()})
class v:lshift=print
Who is?
whoever keeps trying to make code that says that
Not a nice thing to say either way.
It's suitably meaningless.
so how do I present my work? I'm not exactly github savvy
I wrote the two pages there in markdown, but you could just do a brainstorm. That way I could hoover it up and fit it all together nicely when I have time.
I think there's a button for editing pages, which should fork the entire wiki to your account. Then you can inspect the pages' source, if that's what you mean.
yaeh
A warning to all: I do intend to make this a curated thing, rather than putting everything in unedited.
no problemo
Another warning to all: I intend to license this under something pretty permissive. Probably Unlicense or Creative Commons with Attribution.
there's a 0.23% chance i'll accidentally write a SCP article.
If you were to, that's the sort of thing I would edit heavily before including.
ALRIGHT CAPS LOCK IS GOING BACK ON IM GONNA WRITE MORE BATCH
BUT YOU WOULD STILL INCLUDE IT O_O
Unrecognisably.
THE CHANCE OF ME WRITING AN SCP ARTICLE JUST INCREASED TO 23.72%
ALSO I MIGHT ACCIDENTALLY LEAVE CAPS LOCK ON
@snow beacon what do you want me to write about?
ALSO SHOULD WE ADD SECTIONS?
I have no idea about all of that ctypes stuff. That would be helpful.
That's up to you. If you think something is important that won't be covered by what's there, then put it in a new section.
PERHAPS ANOTHER SECTION;
"TELL PYTHON WHAT TO DO, DON'T LET PYTHON TELL YOU WHAT TO DO"
hmm theres a ton there
Our target audience should be an intermediate Python programmer. They might know concepts no more advanced than list comprehensions, unless they're covered by other pages.
The fun stuff with ctypes is monkey-patching, so that would be a good priority.
i can just talk about fishhook and how it works
That would be great.
OR hOw tO MakE A DecENt rIP-ofF OF fIShHook ON thEIR oWN
My poor weary ears...
EARS?
Your volume.
WHAT VOLUME?
The volume of the text, duh
TEXT DOES NOT HAVE VOLUME, IT IS TWO DIMENSIONAL
but are you sure about that
IT AT LEAST IS A REPERESENTATION OF A TWO-DIMENSIONAL COMMUNICATION METHOD
but what if you could hear it
IT MAKES NO NOISE, IT IS A SILENT FORM OF COMMUNICATION DESIGNED TO ENTER A HUMAN BRAIN VIA VISUAL INPUT METHODS, AND EXIT A HUMAN BRAIN VIA APPENDAGES.
THE EARS, MOUTH, OR ANY AUDIO ORGANS ARE NOT INVOLVED IN THIS PROCESS IN ANY WAY.
THE NERVOUS SYSTEM AT ITS EXTREMES IS INCAPABLE OF DISCERNING TEXT UNLESS IT IS DESIGNED FOR VISUAL DISABILITY.
you must feel the text around you
IT FEELS FLAT
Yours feels deafening.
Your text is killing my imagination
Wtf is happening here lol
Hey @floral meteor!
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:
dahecc
@floral meteor i just pushed an update to fishhook that should make it fully version independent
noice
!e ```py
def INSTALL_BATTERIES(C):
if len(C.doc)>72:
S=C.doc+'';C.doc=''
for I,E in enumerate(S):
if I>30 and I%30>=19:C.doc+="Low Battery"[(I%30)-19]
else:C.doc+=E
C.doc+="Power Off"
C.charge=100
return C
@INSTALL_BATTERIES
class BLUETOOTH_HEADPHONES:
"""You will hear voice guidance in the following situations via the headset.
When powering on: “Power on”
When powering off: “Power off”
When entering pairing mode: “Bluetooth pairing”
When establishing a Bluetooth connection: “Bluetooth connected”
When disconnecting a Bluetooth connection: “Bluetooth disconnected”
When checking the remaining battery charge: “Battery about XX %” (The “XX” value indicates the approximate remaining charge. Use it as a rough estimate.) / “Battery fully charged”
When the remaining battery charge is low: “Low battery, please recharge headset”
When automatically turning off due to low battery: “Please recharge headset. Power off”
"""
charge,MANUFACTURER=0,"SONY"
def init(self):self.connected, self.low_battery, self.volume = [], False, 80
def connect(self, device):self.connected+=[device];return self
def disconnect(self,i):return self.connected.pop(i)
def close(self):return exit(print ("Power off"))
def next(self,i=None,__rev=1<0):
if i is not None:return self.connected[i].getattr('prev'__rev or 'next')()
for d in self.connected[::-1]:
try:assert d.is_playing();return d.getattr('prev'__rev or 'next')()
except:0
return 1
prev=lambda s,i:s.next(i,1>0)
def volume(self,n,here=1>0):
if here:self.volume+=n
else:self.volume=n
if self.volume>100:self.volume=100
def use_battery(self):
self.charge-=1
if 1<self.charge<10:print("Low Battery")
elif self.charge<=1:self.close()
def play(self):
for device in self.connected[::-1]:
try:ec=device.resume();assert ec;return ec
except:0
return 1
pause=lambda self:(*[d.pause()for d in self.connected[::-1]if d.is_playing()],)
print (BLUETOOTH_HEADPHONES.doc)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | You will hear voice guidance in the following sitLow Battery the headset.
002 |
003 | WhenLow Batteryn: “Power on”
004 | When Low Batteryf: “Power off”
005 | WhenLow Batteryairing mode: “BluetLow Batteryg”
006 | When establishinLow Batteryth connection: “BluLow Batteryected”
007 | When disconnLow Batteryuetooth connection:Low Battery disconnected”
008 | WhenLow Batteryhe remaining batterLow BatteryBattery about XX %”Low Batteryvalue indicates theLow Batterye remaining charge.Low Batterya rough estimate.) Low Batteryfully charged”
009 | WhenLow Batterying battery charge Low Batteryw battery, please rLow Batterydset”
010 | When automatiLow Batteryng off due to low bLow Batteryease recharge headsLow Batteryff”
011 | Power Off
There we go i finally perfected the annoyingness of bluetooth headphones!
now it should work on 3.10 with no work
3.10 OWO
as long as no new tp_as_* is added
my entire cursedutils will likely collapse in 3.10
even if they change size it should work
@simple crystal fishhook==0.0.8 should work on 3.10
nice,a ny change other than async addition?
I guess I cna look at git
now it generates the layout of structs dynamically
interesting
i realized that on user classes (ie the ones made in python) the structs are located within the types memory
this can be seen here
!e ```py
print(type.sizeof(type))
class A:pass
print(type.sizeof(A))```
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
001 | 408
002 | 1048
so by reading the memory of the type object i can look for pointers that are into the classes memory and use them to calculate struct size and the offset of the pointer in general
!e ```py
from ctypes import *
import sys
base_size = sizeof(c_ssize_t)
wrapper_type = type(int.add)
static_size = type.sizeof(type) // base_size
def mem(addr, size):
return (c_char*size).from_address(addr)
class _scratch:pass
_size = type(_scratch).sizeof(_scratch)
_start = id(_scratch)
_end = _start + _size
_cls_mem = mem(_start, _size).raw
_intermediate = []
for i in range(0, _size, base_size):
_val = int.from_bytes(_cls_mem[i:i + base_size], sys.byteorder)
if _start < _val < _end:
_intermediate.append((i//base_size, _val))
_last_addr = None
_offsets, _sizes = [0], [static_size]
for _offset, _addr in sorted(_intermediate, key=lambda i:i[1]):
if _last_addr is not None:
_sizes.append((_addr - _last_addr)//base_size)
_offsets.append(_offset)
_last_addr = _addr
_structs = tuple(zip(_sizes, _offsets))
print(_structs)
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
((51, 0), (3, 10), (36, 12), (3, 14), (10, 13), (7, 20))
@sick hound :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)>}
nice
I look forward to figuring out exactly what is going on there
appreciate your work as always haha
thanks
feel free to ping me if you have any questions
kk 🙂
there's a way to make that no print globals without hacking any built-ins
print = lambda *_, **__:...?
that's hacking builtins
It does nothing to builtins.
There's that 'redirect stdout' context manager in one of the libraries.
You could also probably close sys.stdout.
okay I'll make the statement itself crash python
You could put an error in the __repr__ of something in the global scope.
!e ```py
@lambda c:c()
class exit:
def repr(self):
try:import('sys').setrecursionlimit(9009); repr(self)
except:repr(self)
print("testings")
print(globals())
print("no printings")
@floral meteor :x: Your eval job has completed with return code 139 (SIGSEGV).
001 | testings
002 | Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow.
003 | Python runtime state: initialized
004 |
005 | Current thread 0x00007faa78f0f740 (most recent call first):
006 | File "<string>", line 4 in __repr__
007 | File "<string>", line 5 in __repr__
008 | File "<string>", line 5 in __repr__
009 | File "<string>", line 5 in __repr__
010 | File "<string>", line 5 in __repr__
011 | File "<string>", line 5 in __repr__
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/bugipiruti.txt?noredirect
mwahahahahaha
!e```py
class x:repr=0
x=x()
print("Printing globals:")
print(globals())
@commands.Bot(command_prefix="!", case_insensitive=True, intents=discord.Intents.all()).command()
async def command(ctx):
await ctx.send("Test")
wait what changed in 3.10 internals 👀
They added a new slot to tp_as_async
In theory my change to fishhook should let it work regardless of if they add/remove slots
That bot would never run
ik
is there a way to get the function obj inside the function itself?
simplier to how self is used inside the class?
you can get the code object using inspect, but I am not aware of any way to the function itself
you can use recursion and execute the function while you define it \
for example ```py
def math_func():
n = 2+2
math_func()
I should probably work on a quick fix for my code then lol, I have a decent idea for how to do it
I wonder if I want to just do only_on(min, max=None)(cprop(...)) or instead cprop(...).only_on(min, max=None) or something
take a look inside fishhook i wrote some code that generates struct sizes/offsets fully dynamically
👀
@grave rover now im working on a way to get the wrapperbase offsets dynamically (without needing to traverse any wrapper struct)
@grave rover https://github.com/chilaxan/fishhook/blob/b35d439ce770133562053dc56b2a86a5f1c32843/fishhook/__init__.py#L19 generate_slotmap does all the magic
@simple crystal @floral meteor ^
major update to fishhook, now it supports all 79 slot backed dunders (and will automatically support any new ones that are added)
depends on the literal, but most literals do not use abstract.c functions at all
and the slots i hook are called from there
ah
!e ```py
import gc
marker = object()
class magic:
def length_hint(self):
return 2
def iter(self):
yield marker
[tup] = [x for x in gc.get_referrers(marker) if type(x) is tuple]
yield tup
T = tuple(magic())
print(T)
print(T[1] is T)```
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
001 | (<object object at 0x7fa7a8785110>, (...))
002 | True
self referring tuple with no ctypes or memory corruption
!e ```py
import gc
class magic:
def length_hint(self):
return 1
def iter(self):
for obj in gc.get_objects():
if isinstance(obj, tuple) and len(obj) == 1:
try:1 in obj
except SystemError:
yield obj
break
T = tuple(magic())
print(T)
print(T[0] is T)```
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
001 | ((...),)
002 | True
better self referring tuple (is is possible to avoid the try/except using repr(obj) but i didnt want to rely on the fact that tuples can represent Null as <NULL>
what would recursion in recursion in recursion look like
Wdym?
I execute a function in a function in a function
You can pass the function through a combinator.
@lambda f: lambda *args, **kwargs: f(f, *args, **kwargs)
def foo(self):
print(self is foo) # True
foo()
That just sounds like recursion.
but I want to do recursion in recursion in recursion
def foo():
def bar():
def bez():
print()
Which can be achieved through recursion.
ouh! even more intresting stuffz niceeee
!e
@lambda f:f.__get__(f,type(f))
def foo(self):
print(self is foo) # True
foo()
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
False
oh
how deep can I go with recursion
!e
import sys
sys.setrecursionlimit(100000)
def foo():
try: foo()
except: foo()
foo()
@viscid nymph :warning: Your eval job has completed with return code 139 (SIGSEGV).
[No output]
Why'd this print False
yeah.. same doubt
just now tried that
!e
def b(f):
return lambda *args, **kwargs: f(f, *args, **kwargs)
@b
def aa(self):
print(self is aa)
aa()
@nimble heron :white_check_mark: Your eval job has completed with return code 0.
False
yeee
Oh it's because I made it a method
heh?
Oh, sorry, foo doesn't refer to the original function anymore.
refers to the wrapped eh
It refers to the wrapped one.
>>> type((lambda:...).__get__(1,int))
<class 'method'>

You could set the __code__ on the original function to the wrapped one, but you'd need to make a copy of it first.
ah, that ruins the magic of it being the original funct
It would be the original function, just with its code edited.
You guys are forgetting walrus operator smh
!e
@lambda f: (x:=lambda *args, **kwargs: f(x, *args, **kwargs))
def foo(self):
print(self is foo) # True
foo()
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
True
👀
Touché. Good spotting.
what does the walrus do here again?
@viscid nymph :white_check_mark: Your eval job has completed with return code 0.
1 1
!e
print(x=1, x)
@viscid nymph :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(x=1, x)
003 | ^
004 | SyntaxError: positional argument follows keyword argument
Yep. You can't use = in expressions.
It came in 3.8.
Ah it's because python < 3.9 is strict for decorators
Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> @lambda f: f
File "<stdin>", line 1
@lambda f: f
^
SyntaxError: invalid syntax
partial partial lol
yikies
!e
from functools import partial
def b(f):
x = lambda *args, **kwargs: partial(f(*args, **kwargs),x)
return x
@b
def aa(*args, **kwargs):
print(x is aa)
aa()
@nimble heron :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 4, in <lambda>
004 | File "<string>", line 8, in aa
005 | NameError: name 'x' is not defined
nop i got no clue
Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from functools import partial
>>> @partial(lambda f: (x:=lambda *args, **kwargs: f(x, *args, **kwargs)))
... def foo(self):
... print(self is foo)
...
>>> foo()
True
can't do it one line though
>>> @getattr('','', lambda f: (x:=lambda *args, **kwargs: f(x, *args, **kwargs)))
... def foo(self):
... print(self is foo)
...
>>> foo()
True
this is an interesting way of doing it
just need a function that returns the lambda
It tries to get ''., which is the empty string attribute of the empty string, and if it fails (it does) returns the lambda.
Unrelated interesting thing:```py
from builtins import bytearray as bytes
I used this sort of thing in a contest recently.
The code defined a function that only threw errors, but used a host of decorators to make it solve the goal of the contest.
I'd love to see a full list of dunders
I feel like they're Easter eggs
@floral meteor you can do from fishhook import generate_slotmap and then print(generate_slotmap().keys())
*that only works on then newest version
these are only the ones backed by slot pointers
there may be other ones (there are)
Also is pypi upgrading as tedious as uploading?
So I just press the setup button then twine uploady stuff?
yea
Well my pc isn't currently connected to internet so I can't hack it from here I might even have to take it out my backpack and do it manually
That sounds arduous. You could always leave pypi unupdated if that's easier.
Try pip install cursedutils==4.2.0
And tell me that could be let unupdated
Do you use semantic versioning?
It's fucking cursed, I accidentally bound half of it to the module itself and one of the functions blue screens but only on windows
Linux doesn't tend to bluescreen, to be fair.
Linux runs it fine but terminates it after it sucks about 10gb of ram
Ahem
Semitic versioning?
Do I have to?
Atm I use cursed versioning, which starts at 4.2.0 and does cursed things
The manifesto is enlightening. It's good to understand, not because it is always the best solution, but because it is always a very good solution. (Unlike some other manifestos.)
And you misspelt it.
Deliberately. See fuckitpy for where I plagiarized that idea from
It's probably pointless to get into whether or not 4.2.0 is 'Semitic' or not.
Probably shoulda started at 0
.0
.1
If I push that version will it be considered later or earlier update?
It would not.
People don't use accurséd versioning because even cursed modules need to update.
I don't doubt it.
Probably woulda got to 4.2.0.1.1.1.1.1.1 before noticing something was wrong
4.2.1 will likely be just as bad, but worse, but more accurate
Esoteric Python and metacoding are essentially the same right?
Metaprogramming is usually pretty not-esoteric. It can be taken off the deep end, though.
hm.
What about programming where the appearance of the code is part of the goal?
What is that called?
Do you mean whitespace versus code, making shapes and all of that? I'm going to steal a term from another field and call it 'concrete' coding.
why concrete tho?
huh. ASCII art with code is esoteric?
I would think so.
are there any good examples in Python?
canary?
Canary.
!e ```py
(lambda ,,,:getattr(getattr(import(True.class.doc[(**)]+True.doc[(*)**+*]+True.class.doc[*(True+)]),import(True.doc[True-]+True.class.doc[(***+)*]+True.doc[(+)__+True]).doc[int(chr(+(*)+)+chr(+(**)+)+chr(+(_*))):int(chr(+(___)+)+chr(+(___)+*)+chr(+(**)))+]),getattr(import(chr((_)**+*)+True.doc[(***+)*]+True.class.doc[True-]),import(chr((*+)*)+True.class.doc[(__*)+*]+True.doc[(+__)*+True]).doc[int(chr(+(**)+)+chr(+(___)+*)+chr(+(**))):int(chr(+(**)+)+chr(+(___)+*)+chr(+(**)))+__]).doc[int(True.int().str()+str(True)+False.int().str()+str(__)):int(True.int().str()+str(True)+False.int().str()+str())+]+getattr(import(chr((__)**+*)+True.doc[int(True.int().str()+True.int().str()+str())]+chr((*)+*)),import(chr(int(True.int().str()+True.int().str()+str()))+True.doc[int(True.int().str()+True.int().str()+str())]+True.class.doc[*(-True)]).doc[int(chr(+(**)+)+chr(+(___)+*)+chr(+(**))):int(chr(+(**)+)+chr(+(___)+*)+chr(+(**)))+]).doc[((-)+*)*____:(-**__)]+True.class.doc[**])(True.doc[**-True].upper()+True.class.doc[**-]+True.class.doc[]+True.doc[True]+True.class.doc[^]+chr((**+**_)*+^)+chr(****+*+True)+chr((*(*)*)+**+*)+True.doc[]+chr((*)**)+True.class.doc[*__]))(True<<True,(True<<True)+True,(True<<True<<True)+True,True.class.doc.find(chr(False)))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World
@snow beacon so what would this be classed as, it evaluates the same in both python and brainfuck:
#[-][
@lambda _:_()
class _:
input,en_in="",True
B=2<<2
__eq__,__ne__=lambda s,o:s,lambda s,o:[setattr(s,'input',o),setattr(s,'en_in',True)]if o is not None else[setattr(s,'input',""),s9etattr(s,'en_in',False)]
__bool__=lambda s:()==()
__int__=lambda s:s.a[s.i]
__str__=lambda s:chr(int(s))
__repr__=lambda s:f"\n<{s.i}: {int(s)}>"
def __init__(s):
s.i=s.o=2>>2
s.a=[s.i] *((2<<s.o)**s.B* 1)
def __pos__(s):
s.o += 1
return s
def __neg__(s):
s.o -= 1
return s
def __add__(s,o):
s.a[s.i] += +(s.o,setattr(s,'o',0))[0]+ 1
s.a[s.i] %= 2**s.B
return s
def __sub__(s,o):
s.o =- +s.o+ 1
s.a[s.i] -= (s.o,setattr(s,'o',0))[False]
s.a[s.i] %= 2**s.B
return s
def __getattr__(s,a):
try:return object.__getattr__(s,a)
except:return print(end=str(s))or s
def __getitem__(s,f):
if type(f)==type(lambda:None):
while int(s):f()
elif f is s:
if s.o:s.a[s.i]=s.o=0
elif int(s):raise RecursionError
elif type(f)is tuple:s(f)
return s
def __gt__(s,o):
s.i += 1
s.a.extend([0]* (s.i- +len(s.a)+ 1))
return s
def __lt__(s,o):
if s.i:s.i -= 1
else:s.a.insert(0,0)
return s
def __rshift__(s,o):
s>o
return s>o
def __lshift__(s,o):
s<o
return s<o
def __call__(s,*a):
if len(a)>1:s.a[s.i]=ord(s.input and[s.input.pop(False)for i in range( +len(a)+ -True)][-True]or '\0'if s.en_in else __import__('sys').stdin.read( +len(a)+ -True)[-True])
elif a is...:(print(s),print(s),print(s),)
return s
#] I think I covered all the bases
if __name__=='__main__':
_++++++++++_ and[
lambda:(((((_>_)++++++++++_)>_)+++++++++++_>_)+++_<<_<_)-_
]>(_>>_)++_<<_
(_++++_)._---_
_._>_
(_--_)._._
(_+++_)._>_
(_._<_)++++++++_
(_._--------_)._+++_
(_._<_)+++++++_
_._--------_
(_._>>_)+_
_._
It's a polyglot.
ployglot!
note the misleading syntax
This just happened without my usual hackery. :/
What if a piece of code is simultaneously polyglot, obfuscated, code art and golfed?
Hopefully it does something interesting.
It'll probably just print hello world, although there's a chance it will instead scrape a cat adoption website and return the details of the fattest cat.
Obfuscated golfed code art often is one and the same.
u can't golf poly glot o.O
Don't tempt them.
!e
print(__doc__)
@simple crystal :white_check_mark: Your eval job has completed with return code 0.
None
!e
"""eyy ima doc eyy"""
print(__doc__)
@simple crystal :white_check_mark: Your eval job has completed with return code 0.
eyy ima doc eyy
!e
exec("""
'eyy ima doc eyy'
print(__doc__)""")
@simple crystal :white_check_mark: Your eval job has completed with return code 0.
eyy ima doc eyy
!e
'eyy im a doc tho'
exec("""
'eyy ima doc eyy'
print(__doc__)""")
@simple crystal :white_check_mark: Your eval job has completed with return code 0.
eyy ima doc eyy
@sick hound :x: Your eval job has completed with return code 1.
001 | bruv
002 | True
003 | Traceback (most recent call last):
004 | File "<string>", line 2, in <module>
005 | TypeError: eval() arg 1 must be a string, bytes or code object
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: eval() arg 1 must be a string, bytes or code object
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | bruv
002 | True
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | bruv
002 | True
003 | (None, 8, None)
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | lol
002 | Ok
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | No
002 | Bruh
wait hold on i know that im 9 days late but are we just going to ignore that font?
Font?
You sweet summer child 😛
OH FUCK YOU
it's all Unicode
you did not
the moment i said it
i realized what you could've done
how can i make space equal to something?
!e
ₚ𝔯𝕚ₙ𝓉(𝔟𝕪ₜᵉ𝓈(m𝔞ₚ(lambda _:ⅈₙᵗ(76+_*(0xfor _ in'?')/3),(-.8,-1.4,0,0,.6,-8.8,-1.4,1.4,.6,1.6,-1.4,1.3,-.6,-1.8,-8.8,2.2,.6,1.3,0,-1.6,-8.6))))
@strange basin :white_check_mark: Your eval job has completed with return code 0.
b'HELLO ESOTERIC WORLD!'
!e
# Wait what?
print('Is anything truthy in an empty array?', any([]))
print('Is everything truthy in an empty array?', all([]))
@strange basin :white_check_mark: Your eval job has completed with return code 0.
001 | Is anything truthy in an empty array? False
002 | Is everything truthy in an empty array? True
lol
!d any
any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:
```py
def any(iterable):
for element in iterable:
if element:
return True
return False
!d all
all(iterable)```
Return `True` if all elements of the *iterable* are true (or if the iterable is empty). Equivalent to:
```py
def all(iterable):
for element in iterable:
if not element:
return False
return True
Yes, I know, but it feels wrong to say that all items are True in a collection and at the same time say that all items are False in that same collection.
yeah seems odd
!e
print(0xfor x in range(10))
@strange basin :white_check_mark: Your eval job has completed with return code 0.
15
!e
for x in ['0' + i * '**0' for i in range(10)]:
print(eval(x), '=', ~len(x) % 2, '=', x)
@strange basin :white_check_mark: Your eval job has completed with return code 0.
001 | 0 = 0 = 0
002 | 1 = 1 = 0**0
003 | 0 = 0 = 0**0**0
004 | 1 = 1 = 0**0**0**0
005 | 0 = 0 = 0**0**0**0**0
006 | 1 = 1 = 0**0**0**0**0**0
007 | 0 = 0 = 0**0**0**0**0**0**0
008 | 1 = 1 = 0**0**0**0**0**0**0**0
009 | 0 = 0 = 0**0**0**0**0**0**0**0**0
010 | 1 = 1 = 0**0**0**0**0**0**0**0**0**0
I have no idea how that even works
(0xf)or
OOH
!e
a = eval('[[0]*6]+'*6+'[]')
a[0][0] = 2
for x in filter(print,a):
break
@simple crystal :white_check_mark: Your eval job has completed with return code 0.
001 | [2, 0, 0, 0, 0, 0]
002 | [0, 0, 0, 0, 0, 0]
003 | [0, 0, 0, 0, 0, 0]
004 | [0, 0, 0, 0, 0, 0]
005 | [0, 0, 0, 0, 0, 0]
006 | [0, 0, 0, 0, 0, 0]
why does this print everything?
print returns None, which is falsey, so the for loop gets an empty iterable and does nothing
ah makes sense
I thought if func was None it checked falsiness of list element but that must literally be if the arg to flter is None
!e
a = eval('[[0]*6]+'*6+'[]')
a[0][0] = 2
@cloud fossil :warning: Your eval job has completed with return code 0.
[No output]
why did this return an output
the filter calls print
the bot is not a REPL, it's running what you provide it as a script
i thought it doesn't do anything until it is being exhausted or whatever
the for loop does just that
that's why I used a for loop
!e
a = eval('[[0]*6]+'*6+'[]')
a[0][0] = 2
for x in filter(print,a):
raise ValueError(I_am_not_defined)
break
@proper vault :white_check_mark: Your eval job has completed with return code 0.
001 | [2, 0, 0, 0, 0, 0]
002 | [0, 0, 0, 0, 0, 0]
003 | [0, 0, 0, 0, 0, 0]
004 | [0, 0, 0, 0, 0, 0]
005 | [0, 0, 0, 0, 0, 0]
006 | [0, 0, 0, 0, 0, 0]
the bot runs python3 {some flags} -i "{your code}"
yo i'm gonna try this at home
it never even reaches body of the for neato
it worked...
but why?
why wouldn't it? a for loop over an empty iterable never happens
print returns None which is falsey, so filter cuts it out
yeah, python is one of the few languages which don't report NameErrors ahead of time
!e
for i in []:
print(1/0)
@cloud fossil :warning: Your eval job has completed with return code 0.
[No output]
😐
!e
print(False and I_am_not_defined)
@proper vault :white_check_mark: Your eval job has completed with return code 0.
False
i thought a falsey and returns the second expression
a truthy and would do that
that would be or
ahgghh
!e py print(False or 'a')
@rugged sparrow :white_check_mark: Your eval job has completed with return code 0.
a
@cloud fossil :white_check_mark: Your eval job has completed with return code 0.
None
the right hand side never gets check for truthiness
it is either ignored, or returned as is
for both and and or
!e
print(True or 1)
@cloud fossil :white_check_mark: Your eval job has completed with return code 0.
True
@cloud fossil :white_check_mark: Your eval job has completed with return code 0.
True
😬

