#esoteric-python

1 messages ยท Page 111 of 1

snow beacon
#

car is just T and cdr is F. That lets you store arbitrary data.

hard spoke
#

Here's some perfectly valid Python mergesort for you people

def m๐šŽ๐‘Ÿ๐—€๐‘’(array, left_index, right_index, middle):
    ๐“ต๐–พ๐˜ง๐œ_๐” ๐’๐›’๐–ž = ๐›ผ๐“‡๐’“๐˜ข๐•ช[๐™ธ๐–Š๐•—๐”ฑ_๐“ฒ๐œ‹๐“ญ๐™š๐’™:(m๐”ฆ๐’…๐’…๐ˆ๐“ฎ + 1)]
    ๐”ฏ๐œ„๐˜จ๐’‰๐ญ_๐“ฌ๐’๐œš๐˜† = ๐›ผ๐“‡๐’“๐˜ข๐•ช[(m๐”ฆ๐’…๐’…๐ˆ๐“ฎ + 1):(๐™ง๐“ฒ๐—ด๐™๐˜ต_๐œพ๐›‘๐“ญ๐–พ๐– + 1)]
    ๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต = 0
    ๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜… = 0
    ๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก = ๐™ธ๐–Š๐•—๐”ฑ_๐“ฒ๐œ‹๐“ญ๐™š๐’™
    while ((๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต < len(๐“ต๐–พ๐˜ง๐œ_๐” ๐’๐›’๐–ž)) and (๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜… < len(๐”ฏ๐œ„๐˜จ๐’‰๐ญ_๐“ฌ๐’๐œš๐˜†))):
        if (๐“ต๐–พ๐˜ง๐œ_๐” ๐’๐›’๐–ž[๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต] <= ๐”ฏ๐œ„๐˜จ๐’‰๐ญ_๐“ฌ๐’๐œš๐˜†[๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜…]):
            ๐›ผ๐“‡๐’“๐˜ข๐•ช[๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก] = ๐“ต๐–พ๐˜ง๐œ_๐” ๐’๐›’๐–ž[๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต]
            ๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต = (๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต + 1)
        else:
            ๐›ผ๐“‡๐’“๐˜ข๐•ช[๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก] = ๐”ฏ๐œ„๐˜จ๐’‰๐ญ_๐“ฌ๐’๐œš๐˜†[๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜…]
            ๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜… = (๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜… + 1)
        ๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก = (๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก + 1)
    while (๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต < len(๐“ต๐–พ๐˜ง๐œ_๐” ๐’๐›’๐–ž)):
        ๐›ผ๐“‡๐’“๐˜ข๐•ช[๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก] = ๐“ต๐–พ๐˜ง๐œ_๐” ๐’๐›’๐–ž[๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต]
        ๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต = (๐ˆ๐ž๐‘“๐žฝ_๐” ๐• ๐™ฅ๐‘ฃœ_๐—‚๐ฟ๐”ก๐’†๐”ต + 1)
        ๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก = (๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก + 1)
    while (๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜… < len(๐”ฏ๐œ„๐˜จ๐’‰๐ญ_๐“ฌ๐’๐œš๐˜†)):
        ๐›ผ๐“‡๐’“๐˜ข๐•ช[๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก] = ๐”ฏ๐œ„๐˜จ๐’‰๐ญ_๐“ฌ๐’๐œš๐˜†[๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜…]
        ๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜… = (๐—‹๐š’๐“ฐ๐˜ฉ๐˜ต_๐–ผ๐žธค๐™ฅ๐›„_๐žฒ๐›‘๐‘‘๐ž๐˜… + 1)
        ๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก = (๐’”๐พ๐˜ณ๐”ฑ๐”ข๐—ฑ_๐“ฒ๐›ก๐“ญ๐“ฎ๐šก + 1)
plucky wedge
#

stop

#

please

#

why

#

imagine making that with that font

#

ew

hard spoke
#

I apologise, I forget the include the driver code, the actual sorting function, and tests

#

oh, and to autoformat. Can't forget that.

floral meteor
#

I'm trying. It not working.
I can't figure out how to make a package, let alone make a package available on pypi

formal sandal
#

@tame kraken a big compactness boost is only using single-letter variables. You probably won't run out of latin ones, but if you do, try cyrillic or greek ones

#

you can also change the indent size to 1

tame kraken
#

sorry, i have to go eat, ill be here after @formal sandal

#

talk to you after

floral meteor
#

k

formal sandal
#

and why do you want to put the program into a QR code?

hard spoke
#

it looks like our hastebin breaks some chars ๐Ÿ˜ฆ

#

literally unusable

#

it look some time to get it right, I had to use pyperclip to stuff the code into my clipboard so I could paste it without it being broken

#

Does this work for y'alls?

floral meteor
#

so how do i upload a module to pypi?

snow beacon
hard spoke
#

yeah, the version I posted is fine

#

when I manually copy the text from the file to the pastebin, though, it breaks for some reason

#

while pyperclip.copy works fine

snow beacon
hard spoke
snow beacon
floral meteor
#

:/

solar dune
snow beacon
solar dune
#

Do you want a link?

floral meteor
#

ya

#

pls

solar dune
floral meteor
hard spoke
#

PyCharm can't handle perfectly valid identifiers, smh

floral meteor
#

so many people poking me to upload cursedutils smh

tame kraken
#

@formal sandal im back from dinner

#

hello everyone, i came here to ask if anyone could improve my code. its not what you think though... i want to make my code as small as possible and im currently sitting at 2.4Kb for the classic Snake Game. i want this to eventually be around 2Kb, ive been doing all i can, and i would greatly appreciate any help from the pro's in here!

#

Also to note, im not using a Compressor or anything like that and im only going to consider using pne when my code is at my goal, and im thinking, 2Kb compressed would be tiny!

floral meteor
#

yikes this package creation process is complicated :/

#

cursedutils-4.2.0

#

pip literally just updated

alpine flower
floral meteor
#

there will only ever be version 4.2.0

#

there's no way im doing all this again for version 4.2.1

#

it's gonna be 4.2.0

#

withe the XD License 6.9

floral meteor
#

lmfao error 403

#

you want to golf your code, my snakey friend?

#

pep8 becomes your guide to what not to do

tame kraken
#

whats pep8?

floral meteor
#

pep8 is the holy grail of readable code.
pep8 is also the bane of esoteric python.

#

!pep 8

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

Active

Created

05-Jul-2001

Type

Process

floral meteor
#

behold

#

pep8

#
Uploading distributions to https://github.com/FluffyTrooper2001/cursedutils
Enter your username: __token__
Enter your password:
Uploading cursedutils-4.2.0-py3-none-any.whl
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 12.3k/12.3k [00:00<00:00, 14.9kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 403 Forbidden from https://github.com/FluffyTrooper2001/cursedutils
Forbidden

Why do i get error?

snow beacon
tame kraken
#

ill paste the code into hastbin and send it

#

im at 2.4 currently

snow beacon
#

That's a lot of extra spaces.

floral meteor
#
Content received from server:
Cookies must be enabled to use GitHub.
snow beacon
#

Try replacing every chain of four spaces with a single space.

floral meteor
#

how do i cookies im in terminal

snow beacon
tame kraken
#

me? how would i remove the spaces?

floral meteor
#

my problem is using twine

snow beacon
#
if x:
    y()
```is the same as```python
if x:
 y()
floral meteor
#

is the same as

x and y()
tame kraken
#

oh

floral meteor
#

:P

#

in that context, anyway

#
if x:y()
#

starting to look more like code, less like glorified English

snow beacon
#

Also, line 32 says game_close == True. Even in regular code, this is a bad idea. It does the same thing as while game_close: on its own.

floral meteor
#

instead of

for iteration in range(len(some_flippity_floppity_funny_looking_array_thingy)):
  do_thing(iteration, some_flippity_floppity_funny_looking_array_thingy[iteration])

You name your variables in one letter if possible, and turn for loops into generator expressions.

[f(i,e)for i,e in enumerate(a)]
#

f,i,e, and a are, respectively, standard abbreviations of instances of function, iteration, element and array

#

think of your keyboard as your namespace. Each key is a variable, operator, or literal. you can still use builtins, but only if they're needed. Try to only name them once. Same as 3rd party API like discord.py

#

!e example of only calling a full name once, only using brackets once, not newline separating classes, only using one letter for names, except for dunders, and not allowing spaces between operators. Only use middleman variables if they will shorten your code.

f=lambda c:c()
@f
class c:__lshift__=print
@int
@f
class n:__int__=69
c<<n
night quarryBOT
#

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

69
floral meteor
#

!e and finally, look for the short way of doing things.

print(69)
night quarryBOT
#

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

69
floral meteor
#

XD

#

I'm trying to do twine upload from terminal, but it's telling me cookies must be enabled to use github :/

#

dammit getpass hates both paste and stdin pipe

#

I'll have to type this mf manually

snow beacon
#

It's probably your terminal emulator. Try pasting with Ctrl+Shift+V.

#

Don't press Ctrl+V first though.

floral meteor
#

I was gonna manually type the whole thing lol

#

what decides a valid classifier?

snow beacon
#

What do you mean?

floral meteor
#
classifiers = [
  "License :: idk :: XD License 6.9", # invalid ;-;
  "Programming Language :: Python :: 3",
  "Programming Language :: Python :: 3.9"
]
#

YAAAAAAAAAAAAAAAAAAAAAAAAAAS

#

I DID IT

#

pip install cursedutils==4.2.0

#

XDDDDD

#

oh no its actually cursed now

#

alright for all those that have been poking me for pypi package, from command line do pip install cursedutils
then from python do

from cursedutils.iostreams import*
#include<iostreams>
int.n.m
cout << "Enter a number between 1 and 10: "
cin >> n
cout << "Enter another number: "
cin >> m
cout << n << " + " << m " == " << n+m

and there's no guarantee that anything will work, as this was just to test uploading.

#

alright how do i update this module, now that I've uploaded it with its many bugs

floral meteor
#

!e ```py
class Given:
def init(s,**k):([setattr(s,this,that)for this,that in k.items()],[setattr(s,this,getattr(s.class,this)(s))for this in dir(s.class)if hasattr(this,'call')and not this[0]=='_'])
def _pep3150_example(a=4,b=5,op=lambda x,y:xy):
"""PEP 3150 example:
op(?.f, ?.g) given bound_a=a, bound_b=b in:
def f():
return bound_a + bound_b
def g():
return bound_a - bound_b
"""
execute_with=lambda
u,**ck:lambda f: f(*u,**ck) # from cursedutils.wrappers import execute_with
@print
@lambda : op(.f, _.g)
@execute_with(bound_a=a, bound_b=b)
class evaluate(Given):
def f(s):return s.bound_a + s.bound_b
def g(s):return s.bound_a - s.bound_b
_pep3150_example()

night quarryBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 18, in <module>
003 |   File "<string>", line 15, in _pep3150_example
004 |   File "<string>", line 13, in <lambda>
005 |   File "<string>", line 3, in <lambda>
006 | TypeError: unsupported operand type(s) for *: 'method' and 'method'
floral meteor
#

what is this base class, chopped liver? I told it to call and reset callable attributes that don't start with _

#

that is the perfect pfp for this module XD

floral meteor
#

!e so tell me, why the distinction? ```py
def lshift(s,o):
print (end=o)
return s
print (lshift.class.name) # function
cout = type("pipe",(),globals())()
cout << cout.lshift.class.name # method

night quarryBOT
#

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

001 | function
002 | method
floral meteor
#

when they seem to be the same thing.

snow beacon
#

They aren't. The method is bound to the cout object, whereas the function takes an s object as an argument.

floral meteor
#

!e

import ctypes
hooker   = ["str",(str,),{}]
hook     = lambda f:hooker[2].__setitem__(f.__name__,f)or f
exec_hook= lambda:ctypes.py_object.from_address(id(str)).__setattr__('value',type(*hooker))
@hook
def encrypt(s,k):return[chr(ord(c).__add__(ord(k[i%len(k)])).__mod__(95)+32)for i,c in enumerate(s)]
@hook
def decrypt(s,k):return[chr(ord(c).__sub__(ord(k[i%len(k)])).__mod__(95)+32)for i,c in enumerate(s)]
exec_hook()
doot = "secret message".encrypt("fluffy")
print(doot)
print(doot.decrypt("fluffy"))
#

bruh

#

Python just ignoring my hacking now.

#

hold up

#

where's the third one coming from?

snow beacon
#

It doesn't need to add so much to the recursion depth โ€” Python calls are expensive.

#

Plus, methods contain a reference to their class.

floral meteor
#

!e

def bind(self):
  def outer(f):
    def inner(*a,**k): return f(self, *a, **k)
    setattr(inner,'__name__',f.__name__)
    setattr(self.__class__,f.__name__,inner)
    return inner
  return outer
cout = type("",(),{})()
@bind(cout)
def __lshift__(self, other):return print(end=str(other))or self
__lshift__(69)
night quarryBOT
#

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

69
floral meteor
#

but in that instance i don't even need to reference the object

snow beacon
#

It sounds to me like you don't normally need any of the distinctions between methods and functions.

floral meteor
#

XD

#

I have a preview module cursedutils available on pypi

#

it's got more bugs than a swamp tho

#

@sick hound
pip install cursedutils

snow beacon
#

Is that Python code?

floral meteor
#

it will be

#

!e ```py
s="""
some song idk
I'm bored.

โ‡†ใ€€โ—ใ€€โšโšใ€€โ–ทใ€€โ†ป
oอœ๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑžoโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌoอœ๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑžo
"""
print(len(s),s,[ord(c)for c in s])

night quarryBOT
#

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

001 | 142 
002 |   some song idk
003 |    I'm bored.
004 | 
005 | 
006 |    โ‡†ใ€€โ—ใ€€โšโšใ€€โ–ทใ€€โ†ป 
007 | oอœ๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑžoโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌoอœ๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑž๏ฑžo
008 |  [10, 32, 32, 115, 111, 109, 101, 32, 115, 111, 110, 103, 32, 105, 100, 107, 10, 32, 32, 32, 73, 39, 109, 32, 98, 111, 114, 101, 100, 46, 10, 10, 10, 32, 32, 32, 8646, 12288, 9665, 12288, 10074, 10074, 12288, 9655, 12288, 8635, 32, 10, 111, 860, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 111, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 9644, 111, 860, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64606, 64
... (truncated - too long)

Full output: https://paste.pythondiscord.com/okotoyaqis.txt?noredirect

floral meteor
#

142 chars and using 64606 likely for the vertical thingys, and 9644 for the horizontal thingys

#

would even be useful if you could trigger an event for clicking on something in the terminal :/

#

i.e. the buttons

#

so then i could make a graphical user interface with just unicode in a terminal

#

so what if i made a fake terminal using a kivy TextInput?
Then i'm free from the limitations of the terminal

#

and i can make an arbitrary object with a touch trigger with the coordinates of the buttons coded in.

#

but then i can't really test it with the bot.

floral meteor
#

!e ```py
class doot:
init=lambda s,d:setattr(s,'d',d)
call=lambda s,o:type("",(),{'rlshift':lambda d,p:setattr(p,o,getattr(p,o)+1)})()
inc, dec = doot(1), doot(-1)
a=type("",(),{})
a.b = 5
a<<inc('b')
print (a.b)

night quarryBOT
#

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

6
floral meteor
#

yaas

#
@call()
class hack_self:
 gulag={}
 def __call__(s, self, new_self):
   hacker = [ctypes.py_object.from_address(id(self)+i)for i in range(16)]
   if id(self)not in s.gulag: s.gulag |= {id(self):[hack.value.copy()if hasattr(hack.value,'copy')else hack.value for hack in hacker]}
   [setattr(hack,value,ctypes.py_object.from_address(id(new_self)+i).value)for i,hack in enumerate(hacker)]
   return self
 def __del__(self):
  """Release prisoner at end of life sentence"""
  for prisoner in self.gulag: ctypes.py_object.from_address(prisoner).value = self.gulag[prisoner]

why does this crash python? ๐Ÿค”

potent comet
#

Well, you're trying to dereference random addresses after the id of an object which isn't valid. You have no idea what's in those bytes, though there's definitely not valid objects 16 bytes from the start of your class instance. Objects are in general randomly placed in memory....

floral meteor
#

you have a good point, but the type of an object is stored at id(obj)+8

#

I would presume there's more data following

sick hound
#

nice rooNice

grave rover
#

^

#

darn you ssize_t

#

Pointers also have variable size depending on the arch ๐Ÿ˜”

simple crystal
#

they're ssize_t sized in cpython distros tho right?

grave rover
#

But hey at least my library supports it, woo

#

Not sure, could be

simple crystal
#

or at least get packed that way in pyobjects

#

is all I care about haha

#

but I checked in c

#

and they are that size when I check in c

grave rover
#

Used for a count of bytes. It is the result of the sizeof
operator. According to the C language standard, it shall
be an unsigned integer type capable of storing values in
the range [0, SIZE_MAX]. According to POSIX, the implementation shall support one or more programming environments where the width of size_t is no greater than the width of the type long.

#

Damn you android copy-paste

#

Actually, i know on my distro that a pointer is as big as a longlong

simple crystal
#

that's huge for a pointer

#

why does it need 64 bits to store a memory address?

grave rover
#

ยฏ\_(ใƒ„)_/ยฏ

#

x64 OSes are weird

simple crystal
#

so your ssize_ts are 8 but your pointers are huge?

#

or are they same size

grave rover
#

Not the same size

#

Huh nvm

#

ssize_t is also 8 bytes apparently

simple crystal
#

I ma getting bytes mixed up

#

yeah

#

your longlongs are 8 bytes?

grave rover
#

But so is a long long apparently

simple crystal
#

interesting

#

I'll check mine

grave rover
#

Longs are same size as long long

simple crystal
#

neve rused a long long

grave rover
#

I think it's because longs are not guaranteed to be bigger than ints?

simple crystal
#

my long longs are 8

#

everything else is 4

#

I think my C is in 32x tho

#

for whatever reason

#

I didn't even install C manually it's just on clion idk what it is

#

pointer:4 long long:8 long:4 size_t:4 ssize_t:4 int:4

#

ah yeah it's building 32 bit

potent comet
stark fable
#

A 32-bit pointer can only address up to 2ยณยฒ locations, which is a little more than 2 gigabytes of RAM.
...2^32 locations is 4 gigabytes

#

but aside from that, yeah, that's what the reason is

#

64-bit pointers are enough for 18 exabytes of RAM which is... a lot

proper vault
#

modern archs only use 48bits for addresssing though

grave rover
#

they still align to 64bit in most cases tho

proper vault
#

ye, its 64bit values, but the high 16 are not part of the address

mild spire
#

Can someone pm and help me reword code so I donโ€™t plagiarise

twilit grotto
#

that's still plagiarism

fossil estuary
#

can someone tell me how this equals 4?
2>>0<<1

proper vault
#

(2>>0)<<1 = 2 << 1

fossil estuary
#

Still unsure

proud bone
#

basically (2>>0)<<1 = 2 << 1 = 2*2

#

(2>>0) = 2 resulting in 2 << 1

fossil estuary
#

then, 2<<2 ?

#

means 2**2?

proud bone
#

2*2*2

#

2<<0 would be 2

fossil estuary
#

thats genuinely confusing.

proud bone
#

Why? just quicked than typing out 2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2

fossil estuary
#

true

#

still seems confusing to me though

proud bone
#

just do this then
2<<10 = 2**11

sudden willow
#

!e __import__("sys").stdout.write(__import__("sys").stderr.mode)

night quarryBOT
#

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

w
rugged sparrow
#

!e ```py
from ctypes import *
import dis

BASE_SIZE = sizeof(c_void_p)
BYTES_OFFSET = b''.sizeof() - 1

def getframe(depth=0):
try:raise
except Exception as e:
frame = e.traceback.tb_frame
for _ in range(depth + 1):
frame = frame.f_back
return frame

def real_return(func):
def wrapper(*args, **kwargs):
class FakeTrue:
def call(self):
py_object.from_address(id(self) + BASE_SIZE).value = bool
instructions[:] = orig
return func(*args, **kwargs)
py_object.from_address(id(True) + BASE_SIZE).value = FakeTrue
frame = getframe(1)
co_code = frame.f_code.co_code
instructions = (c_char * 4).from_address(id(co_code) + BYTES_OFFSET + frame.f_lasti)
orig = instructions.raw
instructions[:] = bytes([
dis.opmap['CALL_FUNCTION'], 0,
dis.opmap['JUMP_ABSOLUTE'], frame.f_lasti
])
return True
return wrapper

class Foo:
@real_return
def contains(self, other):
return (self, other)

night quarryBOT
#

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

(<__main__.Foo object at 0x7f79caca3fa0>, 1)
sudden willow
#

anyone know a quirky way to get the letter o

fossil estuary
#

o?

sudden willow
#

yeah

fossil estuary
#

let me see

sudden willow
#

trying to find a way without using chr/ord

fossil estuary
#

ah.

sudden willow
#

brb

#

wait

fossil estuary
#

that was my first idea lol

sudden willow
#

!e print({}.__class__)

night quarryBOT
#

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

<class 'dict'>
sudden willow
#

sucks

#

wait

fossil estuary
#

hmmm

sudden willow
#

!e print(_:="")

night quarryBOT
#

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

[No output]
fossil estuary
#

found one

sudden willow
#

brb

fossil estuary
#

!e ```py
print("%c"%((2>>0<<6)-17))

night quarryBOT
#

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

o
sudden willow
#

too mathy for me

#

!e print((lambda:....__class__).__str__()[7])

night quarryBOT
#

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

o
fossil estuary
#

o.o

sudden willow
#

alright brb gotta refine code

fossil estuary
#

Amazing.

sudden willow
#

!e

__import__("sys").stdout.write((lambda:....__class__).__str__()[(([]==[])++([]==[])++(([]==[])+([]==[]))++([]==[])++([]==[])++([]==[])+([]==[])+~([]==[])++([]==[]))].__add__(__import__("sys").stderr.mode).__add__((lambda:....__class__).__str__()[(([]==[])++([]==[])++(([]==[])+([]==[]))++([]==[])++([]==[])++([]==[])+([]==[])+~([]==[])++([]==[]))]))
night quarryBOT
#

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

owo
fossil estuary
#

owo

sudden willow
#

uwu

#

yet another esoteric codeblock of mine that just returns owo

fossil estuary
#

now make it return uwu

fossil estuary
#

no

viscid nymph
#

use sys.__stdout__ verycool

rugged sparrow
#

!e ```py
from ctypes import *
import dis

BASE_SIZE = sizeof(c_void_p)
BYTES_OFFSET = b''.sizeof() - 1

def getframe(depth=0):
try:raise
except Exception as e:
frame = e.traceback.tb_frame
for _ in range(depth + 1):
frame = frame.f_back
return frame

capsule = {}

@CFUNCTYPE(py_object, py_object)
def call(_):
tptr = capsule.pop('tptr')
inst = capsule.pop('inst')
orig = capsule.pop('orig')
retv = capsule.pop('retv')
tptr.value = None
inst[:] = orig
return retv

call_addr = cast(call, c_void_p).value

def real_return(func):
def wrapper(self, other):
frame = getframe(1)
co_code = frame.f_code.co_code
flag = co_code[frame.f_lasti + 1]
ret = func(self, other, flag)
instructions = (c_char * 4).from_address(id(co_code) + BYTES_OFFSET + frame.f_lasti)
orig = instructions.raw
instructions[:] = bytes([
dis.opmap['CALL_FUNCTION'], 0,
dis.opmap['JUMP_ABSOLUTE'], frame.f_lasti
])
tpcall_pointer = c_void_p.from_address(id(bool) + 16 * BASE_SIZE)
tpcall_pointer.value = call_addr
capsule.update(tptr=tpcall_pointer,
inst=instructions,
orig=orig,
retv=ret)
return True
return wrapper

class Foo:
@real_return
def contains(self, other, flag):
return (self, other, flag)

print(1 in Foo())
print(2 not in Foo())```

night quarryBOT
#

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

001 | (<__main__.Foo object at 0x7f9aaec89fa0>, 1, 0)
002 | (<__main__.Foo object at 0x7f9aaec89fa0>, 2, 1)
rugged sparrow
#

allows __contains__ to return actual values (not just True or False) and passes a flag based on in vs not in

grave rover
#

!e ```py
with open("/proc/self/maps") as f:
print(f.read())

night quarryBOT
#

@grave rover :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | FileNotFoundError: [Errno 2] No such file or directory: '/proc/self/maps'
grave rover
#

huh

#

I guess I can't use my code here ๐Ÿ˜”

rugged sparrow
#

yea snekbox has procfs disabled

grave rover
#

sad

rugged sparrow
#

you could fake it tho. have open(*args) return a mock file object

#

that actually access the address space

fluid tree
floral meteor
# simple crystal ..or + 4 on 32 bit

oh how do i detect the bitness of a system, then?
oh wait, i know, read _64_bits = hack(id(obj)+8).value == obj.__class__
or _32_bits = hack(id(obj)+4) == obj.__class__
or even ARCHITECTURE ,= [i for i in range(16)if hack(id(obj)+i)==obj.__class__]

floral meteor
snow beacon
#

Isn't there one in io?

floral meteor
#

how would I set what it... does?

snow beacon
#

If I recall, you give it a string, and it pretends to be a file.

floral meteor
#

ah, a string.
I've been making an entirely new File class, that behaves like open() only it doesn't block the file.
after all, whenever i use file reading, i haven't done anything that needs to block it.
here's a preview, I haven't added 'invincibility' yet, since try except suites are bugger to write esoterically.

 __eq__    =lambda s,p:s.name==p.name# or s.read()==p.read() #<review>
 __ge__    =lambda s,t:t[1]<=(t[0],str(s)) # [__str__]
 __and__   =lambda s,o:s and o# []
 __or__    =lambda s,o:s or o # []
 __str__=__repr__=lambda s:s.read() # [read]
 __int__   =lambda s:len([(f:=open(s.name)).read(),f.close()][0]) # [__init__]
 __bool__  =lambda s:os.path.exists(s.name) # [__init__]
 # file-like-methods
 read=lambda s,n =- 1:[(f:=open(s.name,'r')).read(n if n>0 else n and int(s)),f.close()][0]if self.readable else NotImplemented # [__int__]
 write=lambda self, s:[(f:=open(self.name,'w')).write(s),f.close()][0]if self.writable else NotImplemented # [__init__]
 readable,writable,seekable,closed=True,True,True,False # []
 seek=lambda s,p,m=0:setattr(s,'__p',p if not m else s.__p+p if m<0 else int(s)-p)if s.seekable else NotImplemented # [__int__]
 reconfigure=lambda s,d='r+',**k:[setattr(s,n,v)for n,v in({'readable':'r'in d or'+'in d,'writable':'w'in d or'+'in d or'a'in d,'seekable':True}|k).items()]
 # idk
 _CHUNK_SIZE,write_through=8192,False
 close=flush=lambda*a,**k:None # []
 fileno=lambda s:[(f:=open(s.name,'r')).fileno(),f.close()][0] # [__init__]
 buffer=type("None",(object,),{'__doc__':"Does not need a buffer"})()
#

The comments are just dependency tracing

#

except for the first one

#

everything after idk is guessing

snow beacon
#

If you're okay with imports you could do your file closing more safely with e.g. pathlib.

floral meteor
#

but i don't like the whole with open(filename,perms) as file: c=file.read();file.seek(3);file.write("whatever") and all that i just like a nice, concise, explicit
+File(filename) # you get it? 'plus file' add a file XD
File(filename) << "from cursedutils.death import blue_screen_induction_protocol\n"
File(filename) << "blue_screen_induction_protocol()"
__import__(filename) # blue screen go brrrrrr

snow beacon
#

I think that's what pathlib tries to be.

#

I just use it for the handy methods.

#

There's one that reads a whole file, which is usually what I want to do.

floral meteor
#

i saw pathlib recently and i thought hmmm, that might come in handy

#

I've gotten as far with pure python tho :/

#

I havent' fiully impleemented seeking tho

#

also open(filename,'r').reconfigure('w') crashed python

rugged sparrow
simple crystal
floral meteor
#

but ARCHITECTURE ,= [i for i in range(16)if hack(id(obj)+i)==obj.__class__] has a pistol operator!

#

Hi vivid

toxic jewel
#

hi

#

!e
`def def(*args, **kwargs):
return *args, **kwargs

def()
`

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     def def(*args, **kwargs):
003 |         ^
004 | SyntaxError: invalid syntax
toxic jewel
#

sad

floral meteor
#

there's a way around that

toxic jewel
#

!e
def = lambda *args, **kwargs: return *args, **kwargs def()

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     def = lambda *args, **kwargs: return *args, **kwargs
003 |         ^
004 | SyntaxError: invalid syntax
toxic jewel
#

am i just dumb

snow beacon
#

def is keyword โ€” you can't use it as an identifier.

floral meteor
#

!e ```py
@lambda f:globals().update({'def':f})
def func(*a,**k):
return [*a], {**k}
print(globals()'def')

toxic jewel
#

interesting

#

globals() semms like it had alot of esoteric usage

night quarryBOT
#

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

([], {})
floral meteor
#

there you go

toxic jewel
#

!e print(globals().keys())

night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__annotations__', '__builtins__'])
toxic jewel
#

interesting

#

!e print(globals().get(__name__))

night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

None
toxic jewel
#

wait

#

!e print((globals().get(__name__)).__str__()[1])

night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

o
toxic jewel
#

making owo brb

floral meteor
#

!e ```py
@lambda c:c()
class cout:lshift=lambda s,o:print(end=o)or s

cout << bytes.name[0] << int.name[0] << globals.name[0]*2 << (lambda:0).class.name[1] << bytes.name[4] << chr(32) << globals().class.name[:2] << globals().class.name[2]*2 << (lambda:2).class.name[1] << globals.name[6]

night quarryBOT
#

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

biggus diccus
toxic jewel
#

lmao

floral meteor
#

that is called obfuscation :>

distant wave
#

Challenge: write text only using _, a-z, and [] and () and .

#

no "'

#

no :

snow beacon
#

We did it with only A-Z, a-z, , and ()

floral meteor
#

oh, i used :

#

once

toxic jewel
#

ive done that

snow beacon
#

Specifically, only calling functions.

floral meteor
#

nope

distant wave
#

No, " is rpesent

floral meteor
#

"sys"

toxic jewel
#

on other account because too lazy to switch

snow beacon
#

That has = too.

toxic jewel
#

sad

distant wave
#

!e print(SyntaxError.name[0])

night quarryBOT
#

@distant wave :white_check_mark: Your eval job has completed with return code 0.

S
toxic jewel
#

!e print((globals().get(__name__)).__str__()[1]+((__import__("sys").stderr.mode).__str__())+(globals().get(__name__).__str__()[1])

distant wave
#

!e import(SyntaxError.name[0].lower() + SyntaxError.name[1] + SyntaxError.name[0].lower()).stdout.write((lambda:....class).str()[(([]==[])++([]==[])++(([]==[])+([]==[]))++([]==[])++([]==[])++([]==[])+([]==[])+~([]==[])++([]==[]))].add(import(SyntaxError.name[0].lower() + SyntaxError.name[1] + SyntaxError.name[0].lower()).stderr.mode).add((lambda:....class).str()[(([]==[])++([]==[])++(([]==[])+([]==[]))++([]==[])++([]==[])++([]==[])+([]==[])+~([]==[])++([]==[]))]))

night quarryBOT
#

@distant wave :white_check_mark: Your eval job has completed with return code 0.

owo
distant wave
#

You can probably strip out the lambdas

#

and =

#

and do fine

night quarryBOT
#

@distant wave :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: unsupported operand type(s) for |: 'tuple' and 'tuple'
toxic jewel
#

!e print((globals().get(__name__)).__str__()[1]+((__import__("sys").stderr.mode).__str__())+(globals().get(__name__).__str__()[1]))

night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

owo
toxic jewel
#

coded on mobile

#

๐Ÿ˜Ž

earnest wing
#
  • use ().__eq__(()) to get 1
  • use <int>.__add__(<int>) to get more
  • use chr(<int>) to get chars
  • use <str>.__add__(<str>) to get strings
#

only requires adchreq_.()

distant wave
#

0+.chrex()&

#

All python ^

snow beacon
#

What's the & for?

distant wave
#

I think

#

0&0

#

!e print(0&0)

night quarryBOT
#

@distant wave :white_check_mark: Your eval job has completed with return code 0.

0
distant wave
#

hm

#

!e print(0^0)

night quarryBOT
#

@distant wave :white_check_mark: Your eval job has completed with return code 0.

0
snow beacon
#

1^1?

toxic jewel
#

o^o

earnest wing
#

exchr()=+ suffices, there was a discussion yesterday

distant wave
#

ah

earnest wing
#

now, i'd like to test my alternate approach to see if it works...

floral meteor
#

+-[]<>,. also suffices.

distant wave
#

?

snow beacon
#

How does that one work?

floral meteor
#

probs not in python tho

distant wave
#

How do you get a string there

floral meteor
#

XD

toxic jewel
#

making python brainfuck day by day

distant wave
#

exchr()>+

#

works

snow beacon
#

weary sigh Brainfuck, of course.

toxic jewel
#

i wasn't aware exchr is a thing

distant wave
#

hmmm

#

exchr()~+

#

!e print(~())

night quarryBOT
#

@distant wave :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: bad operand type for unary ~: 'tuple'
floral meteor
#

remember the brainfuck i almost made with just class declarations and wrappers?

toxic jewel
#

!e print(exchr().__dir__())

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

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

hm

toxic jewel
#

my dissapointment is immeasurable and my day is ruined

distant wave
#

Hmmmm

#

exchrin()+

#

^

#

!e print(chr((() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])+(() in [()])))

night quarryBOT
#

@distant wave :warning: Your eval job has completed with return code 0.

[No output]
toxic jewel
#

wtf

floral meteor
#
def exchr(*n):
  exec ('%c'*len(n)%n)
distant wave
#

It can be made better, although pretty sure spaces are required...

floral meteor
#

spaces are overrated

distant wave
#

!e ```py
print(chr((()in[()])))

night quarryBOT
#

@distant wave :white_check_mark: Your eval job has completed with return code 0.


distant wave
#

oh

toxic jewel
#

spaces are kinda cr*nge

distant wave
#

my god

earnest wing
toxic jewel
#

wtf

distant wave
#

it works without spaces

floral meteor
toxic jewel
#

in most cases all spaces can be replaced with ()

distant wave
#

exchrln()+

snow beacon
#

You need commas.

earnest wing
#

You can replace the hr in exchr()+= with '% if you want fun syntax.

#

'%c'%n === chr(n)

distant wave
#

eh

#

notc+,

#

and your code is run in exec("%c"*len(code)%code)

#

not sure how that'll work

#

!e ```py
print(not ,)

#

There

toxic jewel
#

!e print(not not ,)

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print(not not ,)
003 |                   ^
004 | SyntaxError: invalid syntax
earnest wing
#

9 distinct bytes is a seemingly lower bound for TC py3

distant wave
#

!e ```py
code = input()
assert not set(code) & {"notc+,"}
exec("%c"%len(code)%code)

toxic jewel
#

is this even python anymore

distant wave
#

absolutely

#

you need some esoteric knowledge to hack this injection attack :P

earnest wing
#

using 1 instead of = makes programs shorter since you can take the char code of 11 instead of 1+1+1+1+1+1+1+1+1+1+1

toxic jewel
#

i know estoeric python sorta well and i have never heard of anything like assert

distant wave
#

!e ```py
assert False

night quarryBOT
#

@distant wave :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | AssertionError
toxic jewel
#

oh my god

earnest wing
#

next up you're gonna say you don't know nonlocal

floral meteor
#

!e assert "False"

night quarryBOT
#

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

[No output]
toxic jewel
#

!e print(assert.__dir__())

floral meteor
#

Wats nonlocal?

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print(assert.__dir__())
003 |           ^
004 | SyntaxError: invalid syntax
toxic jewel
#

rigged

toxic jewel
snow beacon
distant wave
#

exech[]=+

snow beacon
#

Might be hard to call things.

distant wave
#

ugh

#

excgtdi()._+

sudden willow
#

!e print(().__class__.__name__[1]+(__import__("sys").stderr.mode)+().__class__.__name__[1])

night quarryBOT
#

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

uwu
sudden willow
#

ten

#

!e print((~(~((([]!=[])++([]==[]))++([]==[]))))<<((([]==[])++([]==[])))^(([]==[])++([]==[])))

night quarryBOT
#

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

10
floral meteor
#

noice

#

now make python code that when run in brainfuck, does the exact same thing

toxic jewel
#

๐Ÿ˜ณ

floral meteor
#

I'm working on a file-like object with extra iostream dunders

toxic jewel
#

jut using vivid on phone and cityshow on computer

floral meteor
#

I just decided i'd return the object after an operation instead of the data passed to it

#

does __hasattr__ method of object call __getattr__?

terse mortar
#

I assume it checks if getattr:

floral meteor
#

try:getattr(s,o)
except:return False
else:return True

#

like that?

terse mortar
#

Why not just ```py
return getattr(thing)

#

Actually that might not work

floral meteor
#

so that's why it gives recursionerror when i tell it to

def __getattr__(self, other):
  if hasattr(self,other):return super().__getattr__(other)
  else:return print (other)
#

so how do I circumvent this circular referencing and still accomplish the same thing?

terse mortar
#

Try returning getattr without the dunder maybe?

floral meteor
#

it doesn't reach that, i don't think :/

terse mortar
#

Well you are probably getting recursion bc you are using the dunder inside the definition

#

So try to replace the super().getattr blah blah with getattr(self, other)

floral meteor
#

__getattr__ <-
if hasattr <-
whatever(getattr(s,o))<-
getattr <-
obj.__getattr__ back to the start

#

hence it's back to the start before it even gets to return super().__getattr__(other) or else:

#

since hasattr seems to within itself call obj.__getattr__

terse mortar
#

Ahh true

#

Hmm

#

Ig you could try looking at how base python defunded them

#

Or try this ig

x = getattr(self, other)
return x if x != None else return print (other)
floral meteor
#

hm.

try:return super().__getattr__(other)
except AttributeError:return print (other)

Might work actually

terse mortar
#

That might also work

night quarryBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

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

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

floral meteor
#

hehe that doesn't work

#

bad bot

simple crystal
#

....what is a CPython string?

#

Unicode objects?

simple crystal
simple crystal
#

....has anyone done mutable strings?

#

making actual string literals mutable not a class

#

but they would probably have to pretend to be mutable

#

I just mean set item by index notation

#

and maybe some mutable sequence methods

solemn basin
#

thereโ€™s bytearray

#

!e ```py
b = bytearray([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])

print(b, b.decode(), sep=": ")

b[5] = ord("-")

print(b, b.decode(), sep=": ")```

night quarryBOT
#

@solemn basin :white_check_mark: Your eval job has completed with return code 0.

001 | bytearray(b'hello world'): hello world
002 | bytearray(b'hello-world'): hello-world
solemn basin
#

@simple crystal

snow beacon
#

You'd probably want the bytearray in UTF-32 for better index complexity.

toxic jewel
#

!e a="b";print(c with a as c)

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     a="b";print(c with a as c)
003 |                   ^
004 | SyntaxError: invalid syntax
toxic jewel
#

sadge

viscid nymph
#

only if you could do

print(c.read() with open('file.txt') as c)
fossil estuary
#

I will attempt to find a way.

sudden willow
#

!e ~(++++(()<=())%~(()<=())++~(()<=()))-~(()<=())

night quarryBOT
#

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

[No output]
sudden willow
#

TIL you can use as many pluses and minuses as you please

viscid nymph
#

and ~

sudden willow
#

~ changes pos/neg doe

viscid nymph
#

!e

print(~~~~~~~~~~~~~~~~~~~~~~~~~~+~+~+~+~++~++~+~----+~+~+~+~+~~+5+-~~-~~-~+~0<~++++++++3==~~+++++++++++---111)
night quarryBOT
#

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

False
sudden willow
#

just learned i can use not in my math too

#

!e ~(++++(()<=())%~(()<=())++~(()<=()))-(~(()<=())<<(()<=())&~(()<=()))++(()<=())++(~(not()<=()))

night quarryBOT
#

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

[No output]
sudden willow
#

and or

#

!e print(~(++++(()<=())%~(()<=())++~(()<=()))-(~(()<=())<<(()<=())&~(()<=()))++(()<=())++(~(not()<=()))++(()<=()or()<=()))

night quarryBOT
#

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

7
viscid nymph
#

and and

#

and True/False

simple crystal
# solemn basin <@171718574044479489>

nice, but I mean I wondered if anyone has experimented with adding tp_as_mapping mp_ass_subscript aka__setitem__ to string literals so they behave like mutable sequences, though you'd probably want to just make a new string behind the scenes rather than figuring out if the string is interned with multiple references and dealing with that

#

yeah it takes more than just hooking the method and trying to assign self to a new string

#

I'd mess with it more but I have hw

viscid nymph
# simple crystal nice, but I mean I wondered if anyone has experimented with adding `tp_as_mappin...

!e

class MutableStr(str):
    def __new__(cls, *args, **kwargs):
        self = super().__new__(cls, *args, **kwargs)
        self.array = bytearray(ord(i) for i in self)
        return self
    
    def __setitem__(self, key, value):
        if isinstance(key, int):
            value = ord(value)
        elif isinstance(key, slice):
            value = (ord(i) for i in value)
        self.array[key] = value
    
    def __str__(self):
        return self.array.decode()

string = MutableStr('Hello World')
string[5] = '-'
print(string)
string[::] = "lol"
print(string)
night quarryBOT
#

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

001 | Hello-World
002 | lol
simple crystal
#

so you'd need to mess with the internals of the language, in CPython you'd need to at least move some pointers around

#

idk exactly how you'd do it because I'm not sure how to navigate to the relevant struct in the PyUnicodeObject hierarchy but I imagine it can be found by diving into the pointers in the top of whatever a str literal is

#

some sort of PyTypeObject

#

I debate whether to get more into knowing what CPython does or to switch to PyPy

grave rover
#

idk exactly how you'd do it because I'm not sure how to navigate to the relevant struct in the PyUnicodeObject hierarchy but I imagine it can be found by diving into the pointers in the top of whatever a str literal is
:)

grave rover
#

tfw looking into how to do this but not sure where getitem is stored on other classes

bold ruin
#

channel description says "code gore" so heres my simple todo list program

while 1:[[open("todo.txt", "w").write("")].append([open("todo.txt", "a").write(input(f"Enter item {x+1}: ") + "\n") for x in range(int([x if x.isnumeric() else 0 for x in input("How many things to do: ").split()][0]))]) if x == "W" else [print(elem.strip("\n")) for elem in open("todo.txt", "r").readlines()] if x == "R" else [print(elem.strip("\n")) for elem in open("todo.txt", "r").readlines()].append([open("todo.txt", "a").write(input(f"Enter item {x+1}: ") + "\n") for x in range(int([x if x.isnumeric() else 0 for x in input("How many things to do: ").split()][0]))]) if x == "A" else print("Command not understood, please try again") for x in input("Read, wipe & write, or append? (R/W/A):").upper()]
rugged sparrow
#

@grave rover __getitem__ uses 2 slot pointers. one in tp_as_mapping and one in tp_as_sequence. tp_as_mapping.mp_subscript will be called if it is not null. tp_as_sequence.sq_item will only ever be called if the argument is an integer (and mp_subscript is null)

#

str uses unicode_subscript in unicode_object.c

floral meteor
simple crystal
#

can you just override a built-in pyobject with a custom class?

floral meteor
floral meteor
night quarryBOT
#

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

Hello World!
floral meteor
#

wait that didn't segfault

#

it usually segfaults if you don't set its __del__ attribute to a function that restores builtins to their original state :/

#

@simple crystal I bet you didn't know
... << "Hello " < "World!"
could do something in python.

simple crystal
#

I did haha

#

but it's interesting

floral meteor
#

after only one line of initialisation

simple crystal
#

again this ain't my first rodeo 'ol son

#

but that's a neato application

floral meteor
simple crystal
#
p = type('p', (type,), {'__lt__':print})("p", (), {})
floral meteor
#

that's a lot of brackets

simple crystal
#

!e

p = type('p', (type,), {'__lt__':print})("p", (), {})
p < 'eyyy no brackets ehhh'
night quarryBOT
#

@simple crystal :white_check_mark: Your eval job has completed with return code 0.

eyyy no brackets ehhh
floral meteor
#

if you had done pip install cursedutils==4.2.0 or are on my pc you could

from cursedutils.iostreams import *
cout << "Hello World!"
simple crystal
#

well yeah but cursedutils probably has to call somethin

floral meteor
#
p = type('p', (type,), {'__lt__':print})("p", (), {})
p < 'eyyy no brackets ehhh'

is a lot of brackets

simple crystal
#

you can import p from whatever module has p = type('p', (type,), {'__lt__':print})("p", (), {}) in it

floral meteor
#

that's 12 brackets

simple crystal
#

how many brackets in your iostream module?

floral meteor
#

there's a way to print hello world no imports 0 brakcets

simple crystal
#

ah

#

hmmm

floral meteor
#

characters 32, 40, and 41 are forbidden

simple crystal
#

oh you can use []

floral meteor
#

neh, i'll forbid those as well

#

bruh i was having fun here

#

i know you know the answer

rugged sparrow
#

oh whoops

floral meteor
#

that was very slow i think spoony saw it

#

@simple crystal did you see that?

simple crystal
#

no

floral meteor
#

sigh of relief

#

@rugged sparrow come join the fun

#

@simple crystal chilaxin just casually did it in pure python.

#

while you looked away for a moment or whatever you were doing

simple crystal
#

I give up haha how is it done?

floral meteor
#

bruh don't give up

#

you've only been at it for 15 minutes

#

keep trying

#

think of how to call methods without using brackets

#

!e like for example

a = 3 + 4    # <- this
print (a)        #calls
b = 3 .__add__(4)#this
print(b)
night quarryBOT
#

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

001 | 7
002 | 7
floral meteor
#

so + is a shortcut to call __add__ method of something

#

so you want a... shortcut to call print

#

@simple crystal you legit quit?

simple crystal
#

idk how to bind a dunder method without brackets

#

so ya

floral meteor
#

dunder is just one way to call a method or function

#

not the only way

#

think of other ways

#

i'll give you a clue: it is not backwards compatible.

#

i.e. python 3.9 +

#

okay i'll drop a massive clue, have you ever worked with discord bots?

snow beacon
#

You can do it pre-3.9.

#

It's just more code.

floral meteor
#

dm me

#

oh wait

#

yeah you just need to make a statement with an equals sign beforehand

viscid nymph
#

wait you just want to print without brackets?

snow beacon
#

And without imports.

simple crystal
#

o

#
@print
class b:
    pass
#

didn't know decos could be any expression now

viscid nymph
#

a callable that takes a single paramater

#

that implementation would need a meta class

snow beacon
simple crystal
#

!e

@print
class b:
    __str__='hello world'```
night quarryBOT
#

@simple crystal :white_check_mark: Your eval job has completed with return code 0.

<class '__main__.b'>
simple crystal
#

idk

viscid nymph
#

you need to metaclass

#

and lambda ig

rugged sparrow
#

that would be overkill

viscid nymph
#

Can I show one way ๐Ÿ˜ฉ

simple crystal
#

!e```py
a=lambda x:'hello world'
@print
@a
class b:
...

#

idk where bot went but I got it

viscid nymph
#

lol

#

wait

rugged sparrow
#

that uses 2 brackets

viscid nymph
#

lol

simple crystal
#

and using those chars specificially was disallowed

viscid nymph
#

yes

rugged sparrow
#

!e py @print @lambda c:c.__name__ class hello_world:pass

night quarryBOT
#

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

hello_world
simple crystal
#

ah nice

#

!e

a=lambda x:'hello world'
@print
@a
class b:
    ...
night quarryBOT
#

@simple crystal :white_check_mark: Your eval job has completed with return code 0.

hello world
simple crystal
#

there

#

they asked for hello world not hello_world :p

#

but thanks I learned somethin

floral meteor
#

you still have four spaces

viscid nymph
#

can you use __import__ ?

floral meteor
#

that is import

viscid nymph
#

nah

floral meteor
#

it does the importing

#

that's what import inheritly is

viscid nymph
#

print does importing

simple crystal
#

!e

@print
@lambda b: b.a
class b:
    a = 'hello world'
night quarryBOT
#

@simple crystal :white_check_mark: Your eval job has completed with return code 0.

hello world
floral meteor
#

still has four spaces in it

#

I forbode character 32, remember?

viscid nymph
#

!e

@__import__
@lambda c:c.__name__
class __hello__:...
night quarryBOT
#

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

Hello world!
simple crystal
#

lol you had to look up what char that was

#

you said brackets ๐Ÿ˜›

floral meteor
#

i had to look up what char brackets were i already knew ' '==chr(32)

#

i said brackets and spaces

#

!e ```py
@print
@lambda :.doc
class _:"""Hello World!"""

night quarryBOT
#

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

Hello World!
simple crystal
#

but that's 2 spaces

floral meteor
#

i later forbade spaces as well

floral meteor
viscid nymph
#

what lol

floral meteor
#
@print
@lambda _:_.__doc__
class _:"""Hello World!"""

Is far more elegant.

simple crystal
#

but it has 2 spaces

floral meteor
#

true...

alpine flower
#

hold up __doc__ is a thing?

viscid nymph
#

I can get it to one space but that's it

floral meteor
#

dammit now i gotta thonk of a way to make class without space

simple crystal
#

lol you can't decorate something without spaces

#

but gl

viscid nymph
#
@print
@lambda*_:_[0].__doc__
class _:"""Hello World!"""
#

just need to make the class without space

rugged sparrow
#

you cant

floral meteor
#

ah but that uses square brakcets

#

square brackets still brackets

#

although for backwards compatibility probably do

pipe=lambda _:_.__doc__
@print
@pipe
class _:"Hello World!"
simple crystal
#

but you need a space after keywords unless you use a character that isn't legal in names

floral meteor
#

but then you'll need to use square brackets to undo the packing

viscid nymph
simple crystal
#

by tacking stuff onto the challenge you made it impossible lol

floral meteor
#

the clue is in the name "square brackets"

rugged sparrow
#

@floral meteor your challenge is impossible without spaces

floral meteor
#

aight, minimal spaces then

viscid nymph
#
@print
@next
@iter
@lambda*a:a
class _:"Hello World!"
#

woops

#

oof

snow beacon
#

Backslash escapes without a letter just do hex escapes I believe.

floral meteor
#

!e print('\20')

rugged sparrow
#

!e py @print @lambda*_:"hello\32world" class _:pass

night quarryBOT
#

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

helloworld
rugged sparrow
#

1 space

night quarryBOT
#

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


viscid nymph
#

do {} count?

floral meteor
#

they are "squiggle brackets"

viscid nymph
#

rip

#

I thought they were braces KEKWLaugh

floral meteor
#

SQUIGGLE BRACKETS VERY TECHINCAL JARGON

#

!e print('\x20')

night quarryBOT
#

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

 
floral meteor
#

gottim

snow beacon
#

Can't you just do```py
@print
@lambda a:"Hello,\x20World!"
class a:0

floral meteor
#

!e ```py
@print
@lambda :.doc
class _:"""Hello\x20World!"""

night quarryBOT
#

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

Hello World!
snow beacon
#

No spaces, only tabs.

floral meteor
#

!e print("\t")

night quarryBOT
#

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

	
floral meteor
#

that prints four spaces :/

snow beacon
#

I didn't print a tab.

#

Discord seems to have.

floral meteor
#

!e ```py
@print
@lambda :.doc
class _:"""Hello\x20World!"""

night quarryBOT
#

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

Hello World!
floral meteor
#

bruh, discord replaces all \t with \x20\x20\x20\x20

simple crystal
#

lol tab is a good point

floral meteor
#

i'm gonna try to make code that does the same thing in both python and brainfuck

#

for my own sanity, i wont include the initialisation

toxic jewel
floral meteor
#

it would be great if decorators worked for expressions

toxic jewel
#

!e py @print @lambda*_:"hello\32world" type("",(),{...})()

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 3
002 |     type("",(),{...})()
003 |     ^
004 | SyntaxError: invalid syntax
toxic jewel
#

suques

floral meteor
#

!e i hate when this raises error

@print
"""Hello\x20World"""
night quarryBOT
#

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

001 |   File "<string>", line 2
002 |     """Hello\x20World"""
003 |     ^
004 | SyntaxError: invalid syntax
floral meteor
#

you see? That shouldn't raise syntax error. that should pass the triple-quoted string to the decorator

#

triple-quoted strings should be decoratable

rugged sparrow
#

why would they be tho?

floral meteor
#

if that doesn't happen in 3.10 or 3.11 i will riot

rugged sparrow
#

it wont happen

#

decorators are meant for special constructs like functions and classes

floral meteor
#

i'll email the devs snippets of code from this channel to torture them

toxic jewel
#

!e py @print @lambda*_:"hello\32world" lambda:...

night quarryBOT
#

@toxic jewel :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 3
002 |     lambda:...
003 |     ^
004 | SyntaxError: invalid syntax
toxic jewel
#

kinda cringe

simple crystal
#

python 4 will intentionally be designed to avoid what happens here

floral meteor
#

I will still hack it to make esoteric python4 code

toxic jewel
#

introducing python4:
patched some "bugs" (type classes, anything lambda related, true being the same as one, anything an esoteric coder would find interesting)
new print: cout << "Hello, World!";

earnest wing
#

here, a cheating program:

#coding:unicode-escape
@print
@lambda*_:'hello,\32world!'
class\x20_:...
toxic jewel
#

interesting

earnest wing
#

!e ```py
#coding:unicode-escape
@print
@lambda*:'Hello,\32world!'
class\x20
:0

night quarryBOT
#

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

Hello,world!
simple crystal
#

nice

terse mortar
#

Cool

floral meteor
#

!e ```py
#coding:unicode-escape
@print\x0a@lambda*:'Hello,\x20world!'\x0aclass\x20:0

night quarryBOT
#

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

Hello, world!
grave rover
rugged sparrow
#

@grave rover no because there needs to be a slot func that grabs __getitem__ from tp_dict

#

the default slot funcs for normal classes work

#

so you can make a class like py class Foo: __getitem__ = None then grab its mp_subscript and sq_item slot func addresses and set them in the target class

#

then add your custom __getitem__ to the target class tp_dict

#

then call pythonapi.PyType_Modified(cls) on the target class (or reimplement it, it just recursively toggles a bit-flag)

grave rover
#

But mp_subscript needs to be a funcptr, no?

#

Or does that get taken care of by how it's called

rugged sparrow
#

mp_subscript does need to be a func pointer

#

you just grab mp_subscript from Foo and set that value on target

#

my fishhook library on pypi does all of it automatically

thin trout
simple crystal
#

it also copies the structs with the dunder pointers to allocated memory cuz chilaxan said to ensure they didn't deallocate

#

might help to see it all in front of you cuz it took me a long time to decode what fishhook does haha

grave rover
simple crystal
#

for mp_subscript you need to get void pointer to id of class plus 14*size_of_ssize_t to get to the mapping methods pointer

#

then get a pointer to the value of that pointer plus 1*size_of_ssize_t for mp_subscript

#

heap_tp_as_mapping = c_void_p.from_address(id(YOUR_CLASS_HERE) + 14 * size_of_ssize_t)

#

then heap_mp_subscript = c_void_p.from_address(heap_tp_as_mapping.value + 1 * size_ssize_t)

grave rover
#

I mean I have that implemented already

simple crystal
#

ah

grave rover
#
    class Test:
        def __getitem__(self, item):
            return item
    print("mp_ass_subscript ptr:", get_view(id(Test), CPyTypeObject.instance()).tp_as_mapping.mp_ass_subscript)
#

this prints 0

simple crystal
#

it's a binaryfunc

#

is that supposed to be printed by get_view?

grave rover
#

binaryfunc is just a C function pointer type

simple crystal
#

ohhhh

grave rover
#

but Test.__getitem__ is a CPyFunction iirc

simple crystal
#

I don't think a heap class dunder is actually pointed to there

#

I think I found them a few ssize_ts from the head of the struct for some reason?

grave rover
#

Working on mapping out the entire thing (R is interpreted as P when it comes to size/alignment)

#

well i did seem to miss tp_as_sequence but that's fixed now

grave rover
#

I'll be honest I have no clue what pointers are set to what in that giant blob of code lol

simple crystal
#

it's pretty daunting lol

#

any clue as to getting ctypes to not hang when attempting to cast random stuff?

#

would be nice to brute force explore but it's impossible with a loop cuz of that

grave rover
#

I feel like there's something wrong in my typedef, I'm having issues where tp_dict holds the value of tp_base, hmm

simple crystal
#

could like, store current value being used and terminate program externally if it runs too long without output

#

restart with next value to test

#

I assume it's just runnin wild in memory trying to find an end

#

and that's why it ruins everything

grave rover
#

ยฏ_(ใƒ„)_/ยฏ

#
    str_dict = CPyObject.by_reference(x_as_pyascii.ob_type.tp_dict)
    print("mp_ass_subscript ptr:", str_dict)
    str_dict["__getitem__"] = print
    pythonapi.PyType_Modified(py_object(str))
    print("abcdef"[1:6])
``` so what pointers here do I need to change for this to work
#

print(str.__getitem__) gives print, so I'm not sure what else to change

simple crystal
#

ur gettin dict 2 slots from the id of the __dict__ right

grave rover
#

what do you mean?

simple crystal
#

the actual dict of a built-in is usually 2 slots from the id

grave rover
#

str_dict is of type dict, not the mappingproxy

simple crystal
#

oh

#

oh did you create a mapping struct for strings?

#

seems like they'd use sequence

#

or rather for whatever string typeobject you're dealing with

#

I'm gonna go to sleep, good luck

grave rover
#

I didn't, but i don't think that matters does it?

#

Or do i have to set the existing pointer to null

grave rover
#

oh wait I see what chilaxan meant now

grave rover
#

    class Dummy:
        def __getitem__(self, item):
            return None
    dummy = get_view(id(Dummy), CPyTypeObject.instance())
    x_as_pyascii.ob_type.tp_as_mapping.mp_subscript = dummy.tp_as_mapping.mp_subscript  # Set str getitem handler to one that uses __getitem__
    str_dict = CPyObject.by_reference(x_as_pyascii.ob_type.tp_dict)
    str_dict["__getitem__"] = print             # Set __getitem__ to print
    pythonapi.PyType_Modified(py_object(str))   # Handle changes
    "abcdef"[1:4:2]                             # this now prints slice(1, 4, 2)
``` @rugged sparrow ty, works now ๐Ÿ‘Œ
sudden willow
#

!e print((globals().__getattribute__('__getattribute__').__class__.__name__[4]).__add__(__import__('sys').stderr.mode.__str__()).__add__(globals().__getattribute__('__getattribute__').__class__.__name__[4]))

night quarryBOT
#

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

owo
sudden willow
#

using __getattribute__ to __getattribute__ :troll:

viscid nymph
#

getattr better

drifting grove
#

!e Not very impressive, but I turned a for loop into a while loop


class While:
  def __init__(self,cond):self.cond=cond
  def __iter__(self):
    while eval(self.cond):yield

x = 10
for _ in While(' x > 0 '):
  print(x)
  x+=~0
night quarryBOT
#

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

001 | 10
002 | 9
003 | 8
004 | 7
005 | 6
006 | 5
007 | 4
008 | 3
009 | 2
010 | 1
proper vault
#
x = 10
for _ in iter(lambda: x > 0, False):
  print(x)
  x+=~0
``` is also an option
sudden willow
#

lamda

twilit grotto
#

lambda

night quarryBOT
#

@sudden willow :warning: Your eval job timed out or ran out of memory.

[No output]
sudden willow
#

infinite for loop

drifting grove
sudden willow
#

lambda better eye em ow

#

!e ```py
u = {"uwu": lambda: print("uwu")}

u.get("uwu")()

night quarryBOT
#

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

uwu
proper vault
#

why use .get if you just error when you get None anyway?

sudden willow
#

true

#

doesnt u[object] call .get

proper vault
#

no

sudden willow
#

i was not aware there was a difference

proper vault
#

{}['a'] will raise a KeyError, {}.get('a') returns None

sudden willow
#

keyerror is harder to compensate for in one line

proper vault
#

yes, but u.get("uwu")() just errors with None anyway

sudden willow
#

although i think u can check beforehand

proper vault
#

so you want the KeyError

#

not a TypeError: nonetype not callable

sudden willow
#

i used something like print("not in dict") if 'a' not in {} else stuff

#

i think you can use callable() too

proper vault
#

generally, you want to do ```py
u.get(key, default)

sudden willow
#

gotta find my old esoteric command line brb

#

nvm its on another repl

#

probably could do this way better now

rugged sparrow
drifting grove
#

!e I did a for loop. You can't nest it unfortunately, but I'm too tired to come up with a better way.

_For = [0,0,None]
class For:
  def __init__(self,iter,var=None):
    global _For
    if var != None:
      _For[2] = var
    _For[1] = list(iter)
  def __bool__(self):
    global _For
    if _For[0] < len(_For[1]):
      if _For[2] != None:
        globals().update({_For[2]: _For[1][_For[0]]})
      _For[0]+=1
      return True
    else:
      _For = [0,0,'']
      return False

# The 'i' can be left out to not use a variable
while For(range(10),'i'):
  print(i)
night quarryBOT
#

@drifting grove :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
tribal moon
#

I made my own "language" type thingy with Python that also had loops

#

this was the syntax lol py Loop() @ (lambda x=0: (x, x < len(numbers), x + 1)) & inherits( {"Loop": Loop, "numbers": numbers, "hashMap": hashMap} ) > ( "code", "here" )

#

it's a language dedicated to mocking Java :)

grave rover
#

while cond: body can also be done like f = lambda: (not cond) or (body(), f()) iirc

rugged sparrow
#

oh yea @grave rover the benefit of stealing the func pointer from a python class instead of just using CFUNCTYPE is that the func you grabbed handles exceptions correctly

grave rover
#

Oh neat

rugged sparrow
#

it also means you can modify the behavior of base classes in pure python (no imports) because you only need memory r/w

grave rover
#

I wonder what'll happen if i change the base class of str to int

#

Yup

rugged sparrow
#

str.tp_base = int?

grave rover
#

Basically

#

It'd have to be id(int) in my impl but same thing

rugged sparrow
#

@grave rover does your code only use /proc to access python's memory?

grave rover
#

Yup

#

/proc/self/mem is all i needed

autumn saffron
#
from discord import Embed as numpy; _FormATTedstats_onELine= lambda p     ,s       :      numpy   ( title=   f"{p.name_clean}'s stats!"   , type  ='rich'  ,color=   gconf   .DUE_COLOUR)   .   add_field (  name=   'Stats:',   value=    '\n'  .  join ( [ "%s: %s"%t for t in(  zip (  list (s.   keys( ) ) ,[ getattr (p,a  ,s[    a]  )for a in s] )   ) ] ) )

@nocturne saddle

grave rover
#

Why are you importing embed as numpy concern

autumn saffron
#

because why not?

rugged sparrow
grave rover
#

Oh really?

#

What do you use on windows then?

rugged sparrow
#

rn my code abuses LOAD_CONST to make arbitrary pyobjects

autumn saffron
#

same

rugged sparrow
#

so i can make a memoryview that points from 0 -> MAX 64bit int

autumn saffron
#

thats a lot of memory

rugged sparrow
#

^ relevant code is there

autumn saffron
#

is the load_const thing a bug or feature

rugged sparrow
#

i make the custom memory view by first making a bytearray object that points from 0 to max int then turn it into a memoryview so i can use getmem to request subsections

#

@autumn saffron it is due to an optimization, inside the LOAD_CONST bytecode there is no bounds checking

autumn saffron
#

o

#

so a bug or feature

rugged sparrow
#

i also use a second smaller bug in EXTENDED_ARG to overflow oparg to negative if needed

#

definitely a bug

autumn saffron
#

ok so it might be fixed later on?

rugged sparrow
#

its unlikely to be fixed

grave rover
#

And is memoryview readable like a file?

autumn saffron
#

why? is the optimization that big?

rugged sparrow
grave rover
#

Hmm

rugged sparrow
autumn saffron
#

oh

#

ok

grave rover
#

Meh, screw windows anyways

rugged sparrow
#

/proc doesnt exist on darwin either

grave rover
#

Screw darwin

rugged sparrow
#

you could also make a fake file object that maps into ram (which is what procfs does i think)

#

that would be trickier tho

#

why are you so adamant about it being a file object?

grave rover
#

Because rewriting everything right now to use a bytearray would not be a fun experience

rugged sparrow
#

fair enough

grave rover
#

A lot of my code relies on the file object keeping track of the current position and only using offsets, that way i don't have to seek for everything

#

Basically the only time I seek is when i get the address of an object to create a view of

rugged sparrow
#

ah

#

one sec i think there is a way to interpret memory as a file

#

@grave rover io.BytesIO for some reason creates a copy of the passed in buffer

grave rover
#

well yeah because otherwise you could very easily break stuff

rugged sparrow
#

Yeah but it should be using the buffer interface

#

Because if it did that you could pass in any buffer like object and it would just work

grave rover
#

True

rugged sparrow
#

@grave rover what methods do you actually use on the file object

#

cause you could just make a shim class

grave rover
#

I guess I could

#

I only use read, tell, seek and write iirc

rugged sparrow
#

not yet

#

its sorta just my random code github

#

prob wont go on pypi

#

@frozen garnet not a help channel

frozen garnet
rugged sparrow
frozen garnet
#

Thanks

grave rover
#

@rugged sparrow why do you hardcode using LE instead of native byteorder?

#

Also, is that _=memory_backing needed? I'm trying to just return memory but it seems to segfault

rugged sparrow
rugged sparrow
grave rover
#

ah

grave rover
grave rover
#
SSIZE_T = (TUPLE_HEADER - PTR_SIZE) // 2  # TUPLE_HEADER = nPn -> n = (TUPLE_HEADER - PTR_SIZE) / 2

...
    backing_addr = id(memory_backing)
    memory[backing_addr:backing_addr+SSIZE_T] = (2).to_bytes(SSIZE_T, sys.byteorder)  # Prevent GC
    return memory
rugged sparrow
grave rover
#

fair enough

#

but yeah you can use the rest of that snippet to prevent having to make a nested function for keeping a reference

rugged sparrow
rugged sparrow
grave rover
#

oh?

rugged sparrow
#
'little' if memoryview(bytes([1,0])).cast('h')[0]==1 else 'big'```
grave rover
#

that is so nasty I love it

rugged sparrow
#

Afaik .cast defaults to native endian

#

I don't have any big endian stuff rn to test tho

#

@grave rover the technical reason why you need to hold onto memory_backing is because it contains the memory that supports memory. so it looks like this in memory <memory_backing:Bytes_Header, <memory:ByteArray_Header, ByteArray_Data>>

#

so if memory_backing gets freed, it corrupts our fake bytearray memory

grave rover
#

I see

limber orchid
#

hey

#

I'm trying to get this to work: ```py
return True if all(for r in range(rl) for c in range(cl) if k:=r-c in m (if m[k] != matrix[r][c] else m[k] = matrix[r][c])) else False

#

basically, it returns True if the dict m always contains the same value for the key, false otherwise

#

Anyone have a tip how I can get it to work?

#
class Solution:
    def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:
        rl, cl, m = len(matrix), len(matrix[0]), {}
        for r in range(rl): 
            for c in range(cl): 
                if k:=r-c in m: 
                    if m[k] != matrix[r][c]: 
                        return False
                    else: 
                        m[k] = matrix[r][c]``` Basically trying to get this to one line
regal elk
#

cry

final night
#

Is it possible to assign and evalulate a function in the same statement? Trying to abuse conditional eval for if-statement like behavior.

#

something like

#
not conditional or t = funct()
return t
#

I am not sure what the correct syntax would be

sick hound
#

Nya?

final night
#

or will only evaluate the right side if the left side is false

proper vault
#

do you need :=

sick hound
#

U mean if if not conditional or (t:=funct()) ?

final night
#

no

#

I am trying to create if statements using or statements

#

@sick hound

final night
final night
#
def ifstatement(conditional, funct):
    not conditional or (t:= funct())
    try:
        return t
    except NameError:
        return None

# testing
def abc():
    return "abc"
    
a = ifstatement(True, abc)
print(a)
sick hound
#

What is esoteric pyth

simple crystal
#

anything you shouldn't do in code other people are helping to maintain

drifting grove
#

Unless you don't want to be allowed to maintain it anymore

rugged sparrow
#

!e py ifstatement = lambda cond, func:(cond or None) and func() def abc(): return 'abc' print(ifstatement(True, abc))

night quarryBOT
#

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

abc
rugged sparrow
#

@final night ^ that is a more concise version

#

if cond is Falsey, it returns None, otherwise it returns func()

opal owl
#

@hollow rover

hollow rover
opal owl
final night
#

Next i'm trying to figure out how to abuse use conditional execution to simulate an if-else statement

#

Is there a concise way to write this sort of statement?

#
True and (True;print("1")) or print("2")
#

I could wrap print in a lambda statement but I sorta want to avoid having to do that every time

#

Essentially if the statement is true, we eval the first one

#

otherwise we eval the second

#

hmm I wonder if I could use an or

#

oh hey, yeah, that totally works :D

#

this is pretty cool

#
(not True or print("1")) and print("2")
#

now I just need to re-order the operations so it doesn't need parens, if possible

#

I bet I could chain these together

snow beacon
#

True and not print("1") or print("2")?

final night
#

I'll test it

snow beacon
#

(It evaluates to True sometimes.)

final night
#

that one works, yeah

#

looks a lot nicer too

#

actually, that only works for functions that eval to false, bummer

#

so print works but

#

a lot won't work

#

the original one (with the ugly parens) works pretty well with chaining

#

check this out

#
v1 = "a"
(not v1 == "a" or print("a")) and (not v1 == "b" or print("b")) and print("?")
v1 = "b"
(not v1 == "a" or print("a")) and (not v1 == "b" or print("b")) and print("?")
v1 = "c"
(not v1 == "a" or print("a")) and (not v1 == "b" or print("b")) and print("?")
a
b
c
snow beacon
final night
#

that's a good point

snow beacon
#

If you really want to discard a value, you can do (0,func(),)[0].

final night
#

I'm just being oddly specific about trying to get this to work with any function, when in practicality it doesn't really matter

#

XD

snow beacon
#

Or I expect (func(),1)[1] would look better because you can remove the not.

final night
#

ah, nice

snow beacon
#

If you do that to both functions, you could tack and None on the end to make the final expression always evaluate to None.

ebon creek
#

Fun

rugged sparrow
#

@grave rover shorter -> ENDIAN = ['little','big'][1%memoryview(b'\1\0').cast('h')[0]]

grave rover
#

wait why not flip the two so you don't have to do 1%

#

oh wait nvm im dumb

#

wait yeah you can cast it to b and use ['big','little'][memoryview(b'\1\0').cast('b')[0]]

#

or wait

#

nvm I'm dumb

rugged sparrow
#

b is just one byte

#

h is a short

grave rover
#

yeah I'm not have smart

toxic jewel
#

theres no tutorial on it because its just a bunch of tips and tricks you learn over time

viscid nymph
#

By lurking in this channel ๐Ÿ‘€

toxic jewel
#

i learnt by lurking

#

its very stressful trying to get your esoteric code right but when you get it it feels amazing

#

esoteric python feels like brainfuck

#

!e print((globals().get(__name__)).__str__()[1]+((__import__("sys").stderr.mode).__str__())+(globals().get(__name__).__str__()[1]))

night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

owo
toxic jewel
#

could make this better brb

#

!e print(globals().values())

night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

dict_values(['__main__', None, None, <class '_frozen_importlib.BuiltinImporter'>, None, {}, <module 'builtins' (built-in)>])
toxic jewel
#

!e

v = [x for x in globals().values()]
print(v.__len__().__bool__())```
night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

True
toxic jewel
#

lolmao

#

wait

#

!e __import__("sys").stdout.write((globals().get(__name__)).__str__()[[x for x in globals().values()].__len__().__bool__()].__add__(((__import__("sys").stderr.mode).__str__()).__add__((globals().get(__name__).__str__()[[x for x in globals().values()].__len__().__bool__()]))))

night quarryBOT
#

@toxic jewel :white_check_mark: Your eval job has completed with return code 0.

owo
toxic jewel
#

coded on mobile

#

just a bunch of dunders and global abuse

viscid nymph
toxic jewel
#

im aware