#esoteric-python
1 messages Β· Page 45 of 1
average discord
the indentation is hopefully fixed now? i cant see it lmao
??
this has nothing to do with the user
its that mobile discord is bad
I forgot to type "problems" in the end
lol
i love how my split tab is perfectly configured so that the braces align
i made python decorators more readable
can this be golfed further?
import sys
for i in sys.argv[1:]:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))```
import sys
for i in sys.argv[1:]:print(*i)
thats not what it does
!eval
yhyg=["each show say a too"]
for i in yhyg:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))```
:white_check_mark: Your 3.12 eval job has completed with return code 0.
essat ahao coyo hw
import sys
for i in sys.argv[1:]:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))
for i in sys.argv[1:]:s=i.split();print(*map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in map(list,s)])))
thanks
import sys
for i in sys.argv[1:]:s=i.split();print(*(map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in [*map(list,s)]]))))
for i in sys.argv[1:]:s=i.split();print(*map(''.join,zip(*[e+['']*(max(map(len,s))-len(e))for e in map(list,s)])))
for i in sys.argv[1:]:s=i.split();print(*(''.join(w[j]if j<len(w)else''for w in s)for j in range(max(map(len,s)))))
for i in sys.argv[1:]:s=i.split();print(*(''.join((w+'\0'*99)[j]for w in s)for j in range(max(map(len,s)))))
i guess \0 chars are filtered before sending them to stdout
not for me
what happens when you do print('a\0b') ?
without 99 magic constant, +3 chars: ```py
for i in sys.argv[1:]:s=i.split();n=max(map(len,s));print(*(''.join((w+'\0'*n)[j]for w in s)for j in range(n)))
aβ’b
weird
im on windows, using windows terminal
i'm on windows, default command prompt
it's a b
import sys
for i in sys.argv[1:]:s=i.split();print(*(''.join(w[j:j+1]for w in s)for j in range(max(map(len,s)))))
w[j:j+1]
^ that's a nice idea
ha, I have the exact same solution up to variable names
using zip I can get to 112 π€
hmmmm
im stuck at 96
is the 89 similar to your solution above?
because my best solution so far is
what's yours
?
spoiler it
||my 89 uses the *99 trick||
oh.
the same thing i tried earlier :p
yeah ||['']*99|| is smart I didn't think of that
oh-
i bet i know exactly what your solution is
it doesn't use the ||variable (un)packing trick!!||
:0 yay
no, probably not
most readable code in #esoteric-python
i'm traumatized
π₯ π₯ π₯ π₯
this should be in pep8 for decorators
I made a blogpost on it https://rocketrace.github.io/blog/heckorator
up on pypi and github as well :)
I recently published heckorator on pypi. Itβs a cursed little project to make Python decorators more readable. But I actually started (and abandoned) the project 4 years ago!
more readable π
who let bro cook
when we say "readable" we don't mean that a person sitting 100m far from screen should be able to read it
for upcoming code jams can we make it a rule to use this package?
Nice. General feedback: I always love your contributions here, because they're about the parts of esopy I enjoy (playing around), rather than obfuscation/golfing.
Feature requests: Ability to also write entire Python scripts like that (as a giant decorator above an empty function).
that would be insane
would love to see that
imagine saying "I code in decorators in python"
(I bet it isn't even a large change, she already has the "giant wall of @_._@_._-mess" to text converter.)
rookie question but ```py
@a_dec@something
is same as
@a_dec
@something```right?
Multiline input is supported! Each line is in the eval syntactic scope however.
It's the same as @(a_dec @ something), which uses the __matmul__ operator
Right, but I mean not writing a multiline decorator, but just "regular" Python code
uhh what?
I kinda forgot decorators
little
The trick is that there's two kinds of @, only one of which (the unary one) relates to decorators.
I guess so, yeah! The idea behind the package was to poke fun at "concerns about the readability of decorators now that they have more flexible grammar" (this happened in 2020 so not so relevant now, but still a fun concept). So if I were to expand this to full scripts, I would probably use a slightly different framing device. Maybe with even more operators & pixel art π
I remember PEP-614, waited for it for a long time :D
Was so annoyed I couldn't do @lambda: ...
there's been a few really nice peps that just seem to drag on forever
typevar defaults was one
@eval("lambda: ") π
Yeah, I did something similar, defining a noop function; @noop(lambda: ...)
(or maybe it was "identity"? Don't remember)
shadowing builtin id
tbh i do that sometimes with the identity function
also, thank you for the feedback it's lovely to hear!
Hey y'all
Remind me
How do you call code that basically repeats itself whenever you execute it
Like it starts something like XYZ, then it becomes XXYZZ, then XXXYZZZ
I don't think my explanations make any sense
Lmao
Maybe the actual rule is stricter than that
could this actually be golfed 164 chars?
https://open.kattis.com/problems/flagquiz?tab=metadata
my 176 chars (proudly in second place)
z,S=input,',';z()
p=[z().split(S)for i in S*int(z())]
s=[max(sum(x!=y for x,y in[*zip(i,j)])for j in p)for i in p]
print('\n'.join(S.join(i)for i,j in[*zip(p,s)]if j==min(s)))
(sort of) explained
z,S=input,',' # comma and input used more than 3 times
z() # read useless question line
p=[z().split(S) # 2d array of alternatives split by comma
for i in S*int(z())] # iterate string * 2nd line of input num times
s=[max( # get incrogusity for each alternative - the maximum
sum(x!=y for x,y in # num of "changes" to turn i to j
[*zip(i,j)]) # loop and unpack i j like this
for j in p)for i in p] # use nested loops
print('\n'.join( # print all alternatives
S.join(i)for i,j in[*zip(p,s)]
if j==min(s))) # with min incrogusity
π€
cant ... for x,y in[*zip(i,j)] ... just be ... for x,y in zip(i,j) ...
same with ... for i,j in[*zip(p,s)] ...
lol
have you tried using itertools
i dont know if it'd be shorter here but itertools.product is cool
how do you see the leaderboard? I've never used kattis for golfing before
go to any problem metadata > statistics
lemme see what that does
oh nice free 2d array from whatever i give it
yeah
sadly all of the itertools stuff follows good naming conventions, so its too long for our purposes
can you replace the final print with z? since input prints its first arg
seems like a no from testing :/
it would hang waiting for input
163
z=input;z()
p=eval("z().split(','),"*int(z()))
s=[max(sum(x!=y for x,y in zip(i,j))for j in p)for i in p]
*map(print,(','.join(i)for i,j in zip(p,s)if j==min(s))),
the most useful python code: the machine that goes bing!
print('\7')
works best in a batch script or in the terminal
if you want your command line to ring a bell when it's done, simply append && py -c "print('\7')
c code with additional frowny faces!
learning something new every day
just evalling a piece of code repetitively using string multiplication and i can just unpack things in thin air thanks to the last comma
this is next level golfing
got 149 ```py
for i,j in zip(p:=[x[:-1].split(',')for x in[*open(0)][2:]],s:=[max(sum(x!=y for x,y in zip(i,j))for j in p)for i in p]):j==min(s)!=print(*i,sep=',')
142 ```py
for i,j in zip(p:=[x[:-1].split(',')for x in open(0)][2:],s:=[max(sum(map(str.ne,i,j))for j in p)for i in p]):j==min(s)!=print(*i,sep=',')
still don't know 164 though π
-# :3
HUH
OPEN(0) IS A THING
everyone golfing this to insanity
just realised i only know 1% of python so far
alr lemme try to comprehend these
so it turns out the newline exclusion isn't needed so
dont need [:-1]?
ya
!!
137
for i,j in zip(p:=[x.split(',')for x in open(0)][2:],s:=[max(sum(map(str.__ne__,i,j))for j in p)for i in p]):j==min(s)!=print(*i,sep=',')
somehow i already knew about walrus operators but i didnt know you could use it like that
didnt know != was called __ne__ as magic method as well
not sure how that j==min(s)!=print() works tho
short circuiting
it does?
x < y < z -> (x < y) and (y < z)
i always used the latter
j==min(s)!=print() -> (j == min(s)) and (min(s) != print())
(all operands are evaluated only once and only if their part of the comparison is reached)
this seems lua golfable 
so for example if i do -2 < -1 < 0 does -2 < -1 get evaluated to -1 first and then compared with 0?
hmm
i used lua a few times but not for golfing
-2 < -1 gets evaluated to True
then since it's True, -1 < 0 gets evaluated
ohhh
nvm i have no idea how to golf this in lua :p
oof
first glance lua just looked quite powerful for golfing with all those powerful string and table functions
then i realised i had to put end after my for loops
Hmm I thought Python was evaluated right to left
Good to know 
is this a \BELL moment????????????????????
see monty python "meaning of life" for why this is so important
as for why it must be evaluated in python, that is self explanatory
&& echo -ne '\x07'
it's gotta be python, because of the reference to the machine that goes bing in Monty Python's Meaning of Life
perhaps i've got echo implemented with a python script on my machine
but that's implicit. Python coders don't like implicit
do you guys know what modulo is i am 14 so if anyone could explain it a bit simple
wrong channel, but see https://en.wikipedia.org/wiki/Modular_arithmetic
Is there any way to shorten print(chr(F)+chr(I)*(F!=I)), where F and I are integers?
the brackets take precedence over % formatting
I see, then I have to add another pair of parens
no, not on its own
"%c%%c"%F%I
i stand corrected
that's not the full version though
print(chr(F)+chr(I)*(F!=I)) still is much shorter
yeag
but thr double formst tricj is cool
how does it even work?
"%c%%c"%F%I = f"{chr(F)}%c"%I
this is the wrong channel to ask such things
thats modular, they are asking about modulo
it basically returns the remainder in a division https://en.wikipedia.org/wiki/Modulo
>>> 3%2
1
>>> 5%2
1
>>> 4%2
0
>>> ```
next time ask in #1035199133436354600 or #python-discussion
this channel is about writing shortest possible or cursed code
x = 3
y = 2
(x/y-int(x/y))*y```
x - (x//y)*y
divmod(x,y)[1]
(do note: modulo and remainder are different!!)
yes, but its easier to explain that way
also thats what elementary and high schools would teach
elementary schoolers dont know what a modulus is
a mod b = c is the same as a β‘ c (mod b)
if you understand the one, the other follows trivially i think
hence why i linked the one
so the other could be understood
I am talking about the modulo operator in python
neither do [filipino] high schoolers (at least a brief idea in 9th-10th grade)
also modulus != modulo
remainder is known from elementary but not modulo
yes so they teach the modulo operator as it tells you remainder
it does not always
I said thats what THEY teach
C teachers are gonna have an easy time explaining the % operator ^^
those kids don't know what modulo is
I don't know C, can you explain?
python teachers, on the other hand, with negative operands of %....
C uses remainder
ohh
a % b = a - bβa/bβ
\forall (a \in \mathbb{R}), (b \in \mathbb{R} \setminus {0})
where \mathbb{R} is not actually the set of all real numbers but rather all the numbers python is able to represent
(this is ignoring floating point inaccuracies, for simplicity's sake)
for modulo, yea
how?
the sign of the result mainly
remainder has the sign of the dividend
import itertools
thing = lambda string, num: [tup for index, tup in enumerate(list(itertools.product(string, repeat = num))) if index % 2 == 0]
print(thing("ABCD", 2))```
this is equivalent i think
import itertools
thing = lambda string, num: list(itertools.product(string, repeat = num))[::2]
print(thing("ABCD", 2))
modulo has the sign of the divisor and is a result of floor division
remainder has the sign of the dividend and is a result of truncated division
!e ```py
x = -5
y = 2
print(x - int(x / y)*y) # remainder
print(x - x//y * y) # modulo [default]
print(x % y)
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | -1
002 | 1
003 | 1
can this be shorted ive been trying something like this
e=u[0];u=u[1:]+" "
e,*u=u=u[1:]+" "```
~~```py
e,*u=u+" "
is u a string
~~```py
e,*_=u;u=u[1:]
this addsnt the space
my guess is this: ```py
u: str
e: str
before:
u = 'abc'
after
u = 'bc '
e = 'a'
``` so one character is "pulled" from u into e, and space is appended to u
yeah, i forgot about it π
yeag thats the intent probably
im wondering if u must be a string afterwards
or if its only accessed by indexing, etc
if u is allowed to become list[str], then this
is the shortest way, im pretty sure
e=u[0];u=u[1:]+" "
e,u=u[0],u[1:]+' '
i think so also
modulos wrap around
14 = 0 (mod 7)
18 = 4 (mod 7)
20 = 6 (mod 7)
-5 = 2 (mod 7)
remainders dont really
14 / 7 = 2r0
18 / 7 = 2r4
20 / 7 = 2r6
-5 / 7 = 0r-5
remainders actually do wrap around-
wdym both ways
0 - 1 = n - 1 (mod n)
well yes
remainders dont really do that
they do, just at -n instead of 0
but it goes back to 0, not n
n β‘ 0 (mod n)
n-1*
i have no clue what im talking about
remainder of -6 divided by 5 isnt 4
ig
that is correct
r(a, b) = a - s(a) |b| β|a/b|β
m(a, b) = a - bβa/bβ
(unless im misremembering!)
divisible_by = lambda self, arrayOfThingsToDivideBy, arrayOfNumbers : [num for num in arrayOfNumbers if any(num % divisor == 0 for divisor in arrayOfThingsToDivideBy)]```
we need to golf this
divisible_by=lambda x,d,n:[i for i in n if any(n%m==0 for m in d)]```hmm
you just used shorter variable named π
Remainders are weird when not precisely defined. For the remainder of x / y, I think it's reasonable to say -y < remainder < y, but that gives two potential solutions for every division, one negative and one positive, ie -6 / 5 = -1 * 5 + -1 = -2 * 5 + 4. Modulo is a convenient way of picking one, it's always the positive one. math.remainder restricts the bounds on remainder so that there is only ever one solution. I suppose the remainder that was being confused over is choosing the remainder that matches the sign of x, besides 0 which is always positive?
yeah
wow big words
# sdf 23 safs8 5 sdfsd8 sdfs 56 21sfs 20 5 --> [56, 23, 20, 5, 5]
get_array_of_numbers = lambda self, string : sorted([int(num) for num in string.split() if num.isdigit()], reverse=True)
βremainderβ as its typically used picks the sign of a for a/b whereas βmoduloβ picks the sign of b
under the flooring definition of modulo anyway
it's not sadly
What's Esoteric Python
what is the difference between writing esoteric code, and writing obfuscated code?
@karmic pumice can i get your insight on this 
im not sure. i guess esoteric code usually involves doing something in an unusual way, like, an interesting but cursed solution to a problem perhaps, while the goal of obfuscation is just to make the code hard to read / analyze
so esoteric is really just, creating a hacky solution, while obfuscation has the goal of being hard to read and understand what's truly happening. weird, but i understand
Need a help in half string.. with times..
esoteric things are things that aren't commonly known, it doesn't have to be a hacky solution it could be elegant and amazing just not very well known and still be esoteric
!e
_=((()==())+(()==()));__=(((_<<_)<<_)*_);c_matrix=('c%'[::(([]!=[])-(()==()))])*((_<<_)+(_*_))%((__+((_<<_)+(()==()))),((_<<_)<<_),(__+((_<<_)+(_*_))),(__+(((_<<_)<<_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)<<_)+(((_<<_)*_)+((_*_)+_)))),(__+(((_<<_)<<_)+((_*_)+(()==())))),((_<<_)<<_),(__+((_<<_)*_)),(__+(((_<<_)<<_)+((_<<_)+((_*_)+(_+(()==())))))),(__+(((_<<_)<<_)+((_<<_)+(_*_)))),(__+(((_<<_)<<_)+(()==()))),(__+(((_<<_)<<_)+(((_<<_)*_)+_))))
exec("print(c_matrix)", dict().setdefault(c_matrix))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
I Love Polar
Supposed to be "Polar Bears". 
hacky is the wrong word, the more interesting pieces of such code are short snippets that leverage lesser known features in a clever way
?
@karmic pumice ```py
"""
x // f
f @ x
(f @ g) @ x
~(1,2) // print
~{'sep':','} & ~(1,2,3) // print # 1,2,3
"""
import fishhook
import functools
class UnpackedArgs:
def init(self, args=(), kwargs={}):
self.args = args
self.kwargs = kwargs
def __repr__(self) -> str:
parts = []
parts.extend(map(repr, self.args))
parts.extend(f'{k!s}={v!r}' for k, v in self.kwargs.items())
args = ', '.join(parts)
return f'<{args}>'
def __and__(a: UnpackedArgs, b: UnpackedArgs) -> UnpackedArgs:
if not isinstance(b, UnpackedArgs):
return NotImplemented
return UnpackedArgs(a.args + b.args, a.kwargs | b.kwargs)
def call(c, args):
if not isinstance(args, UnpackedArgs):
return c(args)
return c(*args.args, **args.kwargs)
@fishhook.hook(tuple)
def invert(self: tuple, /) -> UnpackedArgs:
return UnpackedArgs(args=self)
@fishhook.hook(dict)
def invert(self: dict, /) -> UnpackedArgs:
return UnpackedArgs(kwargs=self)
@fishhook.hook(object)
def matmul(a: object, b: object, /) -> object:
if not callable(a):
return NotImplemented
if not callable(b):
return call(a, b)
@functools.wraps(b)
def f(*args, **kwargs):
return a(b(*args, **kwargs))
return f
@fishhook.hook(object)
def rfloordiv(a: object, b: object, /) -> object:
if not callable(a):
return NotImplemented
return call(a, b)
yo
idk any other channel that could fit this problem so i just chose this one
from __future__ import annotations
import typing as t
from dataclasses import dataclass
T = t.TypeVar("T")
ObjectT = t.TypeVar("ObjectT")
ObserverT = t.Callable[[T], None]
class ReactiveField(t.Generic[T]):
__slots__: t.Sequence[str] = ("_value", "_observers")
def __init__(self, value: T) -> None:
self._value = value
self._observers: list[ObserverT] = []
@t.overload
def __get__(self, obj: None, otype: type[ObjectT]) -> ReactiveField[T]:
...
@t.overload
def __get__(self, obj: ObjectT, otype: type[ObjectT]) -> T:
...
def __get__(self, obj: t.Optional[ObjectT], otype: t.Optional[type[ObjectT]]) -> t.Union[T, ReactiveField[T]]:
if obj is None and hasattr(otype, "__dataclass_fields__") is True:
return self
return self._value
def add_observer(self, callback: ObserverT) -> None:
self._observers.append(callback)
def __set__(self, obj: ObjectT, value: T) -> None:
self._value = value
for observer in self._observers:
observer(self._value)
@dataclass
class Config:
age: ReactiveField[int] = ReactiveField(1)
config = Config()
callback = lambda hello: print(f"changed to {hello}")
Config.age.add_observer(callback)
print(config.age) # 1
config.age = 5 # changed to 5```
Im trying to create "reactive fields", fields that you can add observers to that are called when the field value changes
Now I got this working which is used with dataclasses.dataclass and its pretty cursed + observers are not actually bound to the instance
Is there a way I could change this so observers only observe a field in one instance? Preferably with a similar syntax?
cant you just use dataclasses.field(default_factory = lambda: ReactiveField(1))
also on what version is this supposed to work because the typehints are deprecated
3.9.13 works fine
typing.Sequence[] is deprecated as of 3.9 no? you're supposed to use it from collections.abc now
idk but anyways how would this solve the issue
it would be created on each instance, and descriptors already work on instances. for adding a callback to a specific instance you could make some function i guess, to not invoke the __get__
well that would override the descriptor in a way, if you did print(config.age) it would print the ReactiveField object
what I thought about is, specifying the instance as parameter in the add_observer method
the problem is, I would have to store the observer functions in a dict, the key being the instance and the value being the list of callbacks for that instance
no you can use inspect.getattr_static to get the actual descriptor on the instance without invoking its get
lemme see
hm ok not sure Im a fan of having to specify the attribute as a string tho, not as user friendly as the dot notation
fair
how bad of an idea is it to follow up on this and make the dataclass hashable despite the fields being mutable
as in ```py
class ReactiveField(t.Generic[T]):
slots: t.Sequence[str] = ("_value", "_observers")
def __init__(self, value: T) -> None:
self._value = value
self._observers: dict[ObjectT, list[ObserverT]] = {}
@t.overload
def __get__(self, obj: None, otype: type[ObjectT]) -> ReactiveField[T]:
...
@t.overload
def __get__(self, obj: ObjectT, otype: type[ObjectT]) -> T:
...
def __get__(self, obj: t.Optional[ObjectT], otype: t.Optional[type[ObjectT]]) -> t.Union[T, ReactiveField[T]]:
if obj is None and hasattr(otype, "__dataclass_fields__") is True:
return self
return self._value
def add_observer(self, obj: ObjectT, callback: ObserverT) -> None:
if obj not in self._observers.keys():
self._observers[obj] = []
self._observers[obj].append(callback)
def __set__(self, obj: ObjectT, value: T) -> None:
self._value = value
for observer in self._observers.get(obj, ()):
observer(self._value)
@dataclass
class Config:
age: ReactiveField[int] = ReactiveField(1)
def __hash__(self) -> int:
return id(self)```
Adding observers as follows:
config = Config()
Config.age.add_observer(config, callback)```
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
https://paste.pythondiscord.com/A2BA
i honestly dont know how it even works but yeah
there's #1035199133436354600 and #python-discussion T^T
e
i saw it
u know when u do alt
and u press random sh
u get a letter or
a character
now hange that +1 at the end to 31
huh
!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +1))
:warning: Your 3.12 eval job has completed with return code 0.
!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +31))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
)
loL
Is there a point in doing any of that? Since its so unreadable and doubt anyone wants to touch and maintain it
!e !e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +33))
ye bro no reason
!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +33))
like it would be awesome
:white_check_mark: Your 3.12 eval job has completed with return code 0.
+
it would be awesome if someone did as a challange
!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +64))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
J
and everyone in the world particiapted on it
J
wathc
!e print(chr((int('0b0001', 2) * int('0x1', 16) + int('0o0', 8) + len('') + (int('0x1', 16) - int('0b0', 2)) + int('1') - int('0') + int('0o1', 8) - int('0b0', 2) + len('a') - len('b') + (int('0x1', 16) + int('0b0', 2) - int('0')) * (1) - int('0x0', 16) + len('') + (int('0b1', 2) * int('0x1', 16) - int('0x0', 16) + (len('') + 1 - len('') + int('0o1', 8) - int('0b0', 2) + (int('0x1', 16) - int('0o0', 8)) - len('') + (int('0b1', 2) - int('0')) + len('a') - len('b') - (int('0x0', 16) + int('0b0', 2) - len('') + (0))) - (int('0b1', 2) + int('0x0', 16) - len('') + int('0o1', 8) - len('') + len('a') - len('b') + int('1') - int('0') + int('0x1', 16) - int('0b0', 2) + len('') - (int('0o1', 8) + len('') - len('b') + int('0x0', 16) - int('0b0', 2)) - len('') + int('0o1', 8) - int('0b0', 2) + int('0x1', 16) - len('') + int('0b1', 2) - int('0x0', 16) + len('a') - len('b') + (int('0b1', 2) * int('0x1', 16) - len('') + (int('0x1', 16) - int('0b0', 2))) - (int('0b0', 2) + len('') - int('0o1', 8) + int('0x1', 16) - int('0b0', 2))) % 31))))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
bum
!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +3))
:warning: Your 3.12 eval job has completed with return code 0.
[No output]
!e print(chr(int('0b1', 2) + int('0x0', 16) * (1 + int('0o0', 8)) - int.from_bytes(b'\x00', byteorder='big') + sum([len('')]) - len('') + int('0x1', 16) * (1 + int('0x0', 16)) - int(float.fromhex('0x1.0p+0')) + len(str(1)) - int('0b0', 2) + len('a') - len('b') + sum([1]) - len('') + (1 + 0 - int('0x0', 16)) * int('0o1', 8) - len('') + (1 + int('0x0', 16)) - int('0b0', 2) + int('0x1', 16) + len('') - len('') + (1 - 0) * int('0o1', 8) - len('') + int(float.fromhex('0x1.0p+0')) - int('0b0', 2) + int('0x1', 16) - len('a') + len('b') - len('') + int('0o1', 8) - int.from_bytes(b'\x00', byteorder='big') +50))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
<
!e '''
and end with three
!e ''''''
!e print("''' '''")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
''' '''
!e print("''' '''")
!e print("''''''''''''''''''''''''''''''''''''''''' '''")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
''''''''''''''''''''''''''''''''''''''''' '''
!e print("''' print("helloworld") '''")
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | print("''' print("helloworld") '''")
003 | ^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 5
002 | )
003 | ^
004 | SyntaxError: unmatched ')'
!e def moo():
big_list = []
while True:
big_list.append('x' * 10**6) # Keep adding large strings to the list
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | print("Heee print("Helloworld") eee LLO ")
003 | ^^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 2, in <module>
003 | print(a.replace(3,"'"))
004 | ^^^^^^^^^^^^^^^^
005 | TypeError: replace() argument 1 must be str, not int
!e !e print("Heee print("Helloworld") eee LLO ")
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | !e print("Heee print(\"Helloworld\") eee LLO ")
003 | ^
004 | SyntaxError: invalid syntax
xd
!e print("Heee print(\"Helloworld\") eee LLO ")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Heee print("Helloworld") eee LLO
!e a = "333 , 333"
print(a.replace("3","'"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
''' , '''
Why not make art?
!e
print('\n'.join([ (11-x)*' '+ ''.join(['* ' for _ in range(x)]) for x in range(1,11, 2)]))
Like this for example
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | *
002 | * * *
003 | * * * * *
004 | * * * * * * *
005 | * * * * * * * * *
οΏΆ
!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print(a.replace(3,"'"))
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 3, in <module>
003 | print(a.replace(3,"'"))
004 | ^^^^^^^^^^^^^^^^
005 | TypeError: replace() argument 1 must be str, not int
!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print(a.replace("3","'"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
'''print("Hello world") '''
hmm i found before a way to change it
!e print('x'**434444)
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | print('x'**434444)
004 | ~~~^^~~~~~~
005 | TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
!e print('x*2'**434444)
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | print('x*2'**434444)
004 | ~~~~~^^~~~~~~
005 | TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
!e print('x'*2**434444)
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | print('x'*2**434444)
004 | ~~~^~~~~~~~~~
005 | OverflowError: cannot fit 'int' into an index-sized integer
!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","'"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
yoo what is goin on '''print("Hello world") '''
!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","'''"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
yoo what is goin on '''''''''print("Hello world") '''''''''
!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","''''"), "\n")
!e
b = 'print("Hello world")'
a = "333" + b + " 333"
print("yoo what is goin on", a.replace("3","''"'"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
yoo what is goin on ''''''''''''print("Hello world") ''''''''''''
it needed to be like im doing smth like that
ye
then u could get out of this black box
!e import os
os._exit(1)
:warning: Your 3.12 eval job has completed with return code 1.
[No output]
llol
oh the black box?
!e import subprocess
subprocess.run([[pip],[uninstall],[pip]],shell=True)
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 2, in <module>
003 | subprocess.run([[pip],[uninstall],[pip]],shell=True)
004 | ^^^
005 | NameError: name 'pip' is not defined. Did you mean: 'zip'?
!e
import random, string
print("".join([random.choice(string.ascii_letters + string.digits) for i in range(8)]))
Random password for this second
!e ```
print('```')
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | /home/main.py:1: SyntaxWarning: invalid escape sequence '\`'
002 | print('\`\`\`')
003 | \`\`\`
!e import subprocess
subprocess.run(['pip', 'uninstall', '-y', 'pip'], check=True)
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 2, in <module>
003 | subprocess.run(['pip', 'uninstall', '-y', 'pip'], check=True)
004 | File "/lang/python/default/lib/python3.12/subprocess.py", line 548, in run
005 | with Popen(*popenargs, **kwargs) as process:
006 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
007 | File "/lang/python/default/lib/python3.12/subprocess.py", line 1026, in __init__
008 | self._execute_child(args, executable, preexec_fn, close_fds,
009 | File "/lang/python/default/lib/python3.12/subprocess.py", line 1953, in _execute_child
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/U6RN3MVSPRMT3HOSIB4WXWXRZA
:white_check_mark: Your 3.12 eval job has completed with return code 0.
F2Efmift
ye
!e `
print('```')
`
`
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | print('
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 1)
damn
!e `
print('```')
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | print('
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 1)
'''
!e print("Hello world")
'''
!e print("Hello world")
a = "'''"
print("what")
b="'''"
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Hello world
:white_check_mark: Your 3.12 eval job has completed with return code 0.
b'`'
!e ```print("Hello world"); a ="'''"'''
'''
'''
'''
'''
'''`
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 7
002 | '''`
003 | ^
004 | SyntaxError: invalid syntax
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | "
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 1)
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | a="
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 1)
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Code block escape attempt detected; will not output result
Full output: https://paste.pythondiscord.com/5DGFKNXTVB3HKPWMGL2QUSI5OQ
xddddddd
WHAT
:white_check_mark: Your 3.12 eval job has completed with return code 0.
He said, "Hello, world!"
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Code block escape attempt detected; will not output result
Full output: https://paste.pythondiscord.com/6MLKMK5PUNZDRE6YPZ3AAH7XVQ
lol
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | Byte representation of the backtick character:
002 | \x60
!e ```
a= "333,333"
print(a.replace("3","`"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Code block escape attempt detected; will not output result
Full output: https://paste.pythondiscord.com/PPMYOO2C2TDQZJWRIJ24USHOCU
!e ```
a = "333"
print(a.replace("3","`"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Code block escape attempt detected; will not output result
Full output: https://paste.pythondiscord.com/IIOG3P4LVYIH464OAMDSGSDNCQ
!e`
Β» equals-true
Β» empty-json
Β» exit()
Β» environments
Β» envs
Β» except
Β» on-message-event
Β» for-else
Β» enumerate
!e eval("pip uninstall")
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | eval("pip uninstall")
004 | File "<string>", line 1
005 | pip uninstall
006 | ^^^^^^^^^
007 | SyntaxError: invalid syntax
!e a=5 print(a)
:white_check_mark: Your 3.12 eval job has completed with return code 0.
5
!e a="333,333,444,555,333,444" print(a.replace("4","``````"))
!e py user_input = "__import__('os').system('rm -rf /')" eval(user_input)
:warning: Your 3.12 eval job has completed with return code 0.
[No output]
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 2
002 | print(a.replace("4","
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 2)
!e a="333,333,444,555,333,444" print(a.replace("4","``````"))
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 2
002 | print(a.replace("4","
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 2)
error
there is no error here
but it gives error :v
new hack
!e a="333,333,444,555,333,444" print(a.replace("4","``````"))
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 2
002 | print(a.replace("4","
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 2)
!e a="333,333,444,555,333,444" print(a.replace("4","``````"))
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 2
002 | print(a.replace("4","
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 2)
we should try something else
!e a="333,333,444,555,333,444" print(a.replace("4",""))
``
`
print("Test")
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 2
002 | print(a.replace("4","
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 2)
what to do tho
===
]]]
~~~
'''
,,,
\\\
!e a="333 OMG WRONG ANSER 333"
print(a.replace("3", "~"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
~~~ OMG WRONG ANSER ~~~
:white_check_mark: Your 3.12 eval job has completed with return code 0.
~~~ OMG WRONG ANSER ~~~
Hi
ouch
just one test
YAAAAAAAAAAAAa
how
test
oj
!e a = "333,444,555,666,111,333,111,555,666,444" print(a.replace("3","~")) print(a.replace("4",""))
print(a.replace("5","#"))
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 3
002 | print(a.replace("4","
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 3)
!e a = "333,444,555,666,111,333,111,555,666,444" print(a.replace("3","~")) print(a.replace("4","")) print(a.replace("5","#"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | ~~~,444,555,666,111,~~~,111,555,666,444
002 | 333,,555,666,111,333,111,555,666,
003 | 333,444,###,666,111,333,111,###,666,444
!e ```
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))
print(''.join(part.replace('4', '') for part in a.split(',')))
print(''.join(part.replace('5', '#') for part in a.split(',')))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | ~~~444555666111~~~111555666444
002 | 333555666111333111555666
003 | 333444###666111333111###666444
!e `
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))
print(''.join(part.replace('4', '') for part in a.split(',')))
print(''.join(part.replace('5', '#') for part in a.split(',')))
`
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | ~~~444555666111~~~111555666444
002 | 333555666111333111555666
003 | 333444###666111333111###666444
!e ```
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))
print(''.join(part.replace('4', ''') for part in a.split(',')))
print(''.join(part.replace('5', '#') for part in a.split(',')))
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 4
002 | print(''.join(part.replace('4', ''') for part in a.split(',')))
003 | ^
004 | SyntaxError: unterminated triple-quoted string literal (detected at line 6)
!e ```
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))
print(''.join(part.replace('4', "'") for part in a.split(',')))
print(''.join(part.replace('5', '#') for part in a.split(',')))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | ~~~444555666111~~~111555666444
002 | 333'''555666111333111555666'''
003 | 333444###666111333111###666444
!e ``
a = "333,444,555,666,111,333,111,555,666,444"
print(''.join(part.replace('3', '~') for part in a.split(',')))
print(''.join(part.replace('4', '') for part in a.split(',')))
print(''.join(part.replace('5', '#') for part in a.split(',')))
``
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | ~~~444555666111~~~111555666444
002 | 333555666111333111555666
003 | 333444###666111333111###666444
fk it
!e ```py
import random
def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
else:
image += '. '
image += '\n'
return image
print(make_image(10,10))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | . . . . . . . . . .
002 | . . . . . . . . . @
003 | . . . . . . . . . .
004 | . . . . . @ . . . .
005 | . . . . . . . . . .
006 | . . . . . @ . . . @
007 | . . . . @ . . . . .
008 | . . @ . @ . . . . .
009 | . . @ . . . . @ . .
010 | . . . . . . . . . @
image maker
!e ```py
import random
def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
else:
image += '. '
image += '\n'
return image
print(make_image(10,10))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | . @ . . . @ @ . . .
002 | . . . . @ . . . . .
003 | . . . @ . . @ . . .
004 | . . . . . @ . . . .
005 | . . . . . . . @ . .
006 | . . . @ . . . . . .
007 | . . . . . . . . . .
008 | . @ . @ . . . . @ .
009 | . @ . . . @ . . . .
010 | . . . . . . . @ @ .
!e``` import random
def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
elif Chance(8):
image += '$ '
elif Chance(16):
image += '^ '
elif Chance(32):
image += '~ '
elif Chance(64):
image += '# '
elif Chance(128):
image += '& '
elif Chance(256):
image += '{ '
elif Chance(512):
image += '} '
elif Chance(1028):
image += '! '
elif Chance(2048):
image += '\ '
else:
image += '. '
image += '\n'
return image
print(make_image(10,10))```
:x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | import random
003 | IndentationError: unexpected indent
!e ```py
import random
def Chance(x:int) -> bool:
if random.randint(1,x) == x:
return True
return False
def make_image(w,h) -> str:
image = ''
for y in range(h):
for x in range(w):
if Chance(2):
image += '. '
elif Chance(4):
image += '@ '
elif Chance(8):
image += '$ '
elif Chance(16):
image += '^ '
elif Chance(32):
image += '~ '
elif Chance(64):
image += '# '
elif Chance(128):
image += '& '
elif Chance(256):
image += '{ '
elif Chance(512):
image += '} '
elif Chance(1028):
image += '! '
elif Chance(2048):
image += '\ '
else:
image += '. '
image += '\n'
return image
print(make_image(10,10))```
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | . . . . . . . . . #
002 | . & . . @ @ ^ $ . @
003 | @ . . . . . . @ . .
004 | . @ . . @ . . . @ ^
005 | . @ . . . . @ . . .
006 | @ . . $ $ . . @ . .
007 | . . . . . . . . . .
008 | . . . . . . . . . @
009 | . . . . . . . . . .
010 | . . @ . . # $ . . .
Can something like (condition and value or"") be golfed further? (where condition is a bool and value is a string).
I would love to do value*condition but I need value to be evaluated lazily
not with just that code
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | exec("".join(map(chr,[72,101,108,108,111,32,87,111,114,108,100,33])))
004 | File "<string>", line 1
005 | Hello World!
006 | ^^^^^
007 | SyntaxError: invalid syntax
provide some code
did you really think this would work
yeah
welcome to esopy, land of the ccursed
I wouldn't call it cursed
It was a sad attempt at a sandbox escape
if someone manages to escape it does it get banned or smt?
thats not cursed, thats what happens when someone tells you address of #esoteric-python when you asked for address of #bot-commands
You do realize they fixed it 6y ago (at least) from plainly looking at the gut blame for last edit
Or maybe you should go #python-discussion
tfw we're not even trying to do that
thats over in #bot-commands
!e a = 333444555666777888999000111222 print(f'{a:,}')
:white_check_mark: Your 3.12 eval job has completed with return code 0.
333,444,555,666,777,888,999,000,111,222
!e i = 1 while True: print(f'{i:,}') i += 1
:x: Your 3.12 eval job has completed with return code 143 (SIGTERM).
001 | 1
002 | 2
003 | 3
004 | 4
005 | 5
006 | 6
007 | 7
008 | 8
009 | 9
010 | 10
... (truncated - too many lines)
Full output: too long to upload
!e i = 1 while True: print(f'{i:,}') i += i
:x: Your 3.12 eval job has completed with return code 143 (SIGTERM).
001 | 1
002 | 2
003 | 4
004 | 8
005 | 16
006 | 32
007 | 64
008 | 128
009 | 256
010 | 512
... (truncated - too many lines)
Full output: too long to upload
wrong channel
go to #bot-commands
oh
lul
There's just flood with people just running eval in this channel
I get it, eval = evil and esoteric is evil, but don't come here unless you have a esoteric intend:)
!py
Why Avoid System Python for Development on Unix-like Systems:
- Critical Operating System Dependencies: Altering the system Python installation may harm internal operating system dependencies.
- Stability and Security Concerns: System interpreters lag behind current releases, lacking the latest features and security patches.
- Limited Package Control: External package management restricts control over versions, leading to compatibility issues with outdated packages.
Recommended Approach:
- Install Independent Interpreter: Install Python from source or utilize a virtual environment for flexibility and control.
- Utilize Pyenv or Similar Tools: Manage multiple Python versions and create isolated development environments for smoother workflows.
:white_check_mark: Your 3.12 eval job has completed with return code 0.
hello world
this is esoteric because no one expects anyone who knows what esopy is to run a normal hello world in the esopy channel
Ever heard of people complaining that python doesn't have multi line comments? We have them... and much more. We have a lot of ways for creating comments, here are some of them in a comprehensive python Hello World! program. Why no one uses them?
!e ```py
"a simple 'Hello World!' program in python"
@(lambda x: x or "this is a function declaration, you can call it later")
def hello():
print("Hello", "World!", end="\n", sep=" ")
"""
Where arguments are:
"""
1; "Hello" # first value
2; "World!" # second value, will be glued to the first value
3; end="\n" # ending for the text, it is appended at the and of the final string
4; sep=" " # when joining multiple values for printing, this will be inserted in between them, so in this case:
"Hello" + " " + "World!" + "\n"; "will be done"
f"And here's how you call a function: { hello() }"
if not ...:
"required" not in "credits"
license = None
0\
/0x0\
<3
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Hello World!
/0x0\
why does no one use them
proceeds to use the one way that no one does
tfw
i mean it is eospy
ive been using python for almost 2 years now and this still fried my brain π
also isnt having an eval command on a public bot kinda risky?
like couldnt someone just eval this
import os
os.system("sudo rm -rf /")
the staff on this server say it's sandboxed, I'm assuming they are very experienced so they know how to do it safely
you can try!
or on that note run a crypto miner
if you find any vulnerability, just make sure to report it to the staff o7
I don't know, I usually go to https://discord.com/channels/267624335836053506/267659945086812160 when I need it
if i do find a vulnerability then it wouldnt be very nice to discover it in a public channel
you can, but you will get just a couple of seconds of cpu time
/j
It was fun to make.
and forget about you have no network
so you couldn't download the transaction data/upload your result anyway
the sandbox technology used is open sourced and you can test+report that way
and remember to follow the security policy of the repository if you find a vulnerability
you can provide newest data in source code (you have 2k character limit btw π )
do you not have to constantly updating the data in real time?
or how certain amount of time delay is allowed
and the 2k include the calculation and output
good golfing exercise :)
(I don't even know how the formatting and stuff work lmao
maybe we could test the hash rate of the eval command
!e
import hashlib, time
start = time.perf_counter()
hash_count = 0
PRE_CHECK = 200000
while True:
for i in range(PRE_CHECK):
hashlib.sha256(b"a").hexdigest()
hash_count += PRE_CHECK
print(f'{hash_count/(time.perf_counter()-start)}')
:x: Your 3.12 eval job timed out or ran out of memory.
001 | 1733476.270807509
002 | 1735724.3620274302
003 | 1759635.260845237
004 | 1774141.9768671254
005 | 1769302.253515442
006 | 1769625.5134471557
007 | 1772058.161462909
008 | 1779751.23899121
009 | 1780753.8825872606
010 | 1783501.2218866139
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/ODD6W272DM3UOLQKRC323ZEIQU
about 1800000 hash/s
I don't think it have any value
lul
consider an rtx 4090 have hash rate of 21975.5 MH/s
it is python, reaching a million of something per second is challenging
well, just a fu fact that it is zero value so you shouldn't even try
not get start with the input and output
the technically diffculty doesn't worth the value it could provide
(also this show it is a fairly powerful machine because my raspberry pi can only run 1000000 hash/s
what can you on your PC achieve?
pasted the code here https://www.online-python.com/ and got 400k/s
No clue lul, I code using remote feature on raspberry pi and too lazy to setup on my macbook
But I think MacBook would be lower since it run more random stuff
i get 1.05 million/s
also relatable how my macbook is 9y old and my raspberry pi is 5gen
i get β 1,900,000 hashes/s with python 3.9.16
and β 1,650,000 hashes/s with both python 3.11.9 and python 3.12.5
interesting
performance degradations...
Can't win all the micro benchmarks π
its probably a lot better with 3.13
since doing the same thing in a loop a bunch of times is like perfect for jit lol
w
!e
import base64
def f23033123(code:str)->None:
codes=code.split()
pri=False
for i in codes:
fij389=""
fij389 = "fdasfadsfasafdsadfsadfs" if base64.b64encode(i.encode()).decode()=='fDMxOCdGZGk=' else fij389
if fij389:
pri=True
if fij389: continue
if not pri: continue
if i!=":3": continue
j01238fjdojdao123=print
j01238fjdojdao123(base64.b64decode("SGVsbG8gV29ybGQh").decode())
f23033123("|318'Fdi :3")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Hello World!
^ *(([^ ]{1,7}[^ ]{9,]|\|[^ ]{7}|[^ ]3[^ ]{6}||[^ ]{2}1[^ ]{5}|[^ ]{3}8[^ ]{4}|[^ ]{4}'[^ ]{3}|[^ ]{5}F[^ ]{2}|[^ ]{6}d[^ ]|[^ ]{7}i) {1,})*?(\|318'Fdi )(([^:][^ ]|[^ ][^3]|[^ ]{3,}|[^ ]) {1,})*?:3( {1,}([^:][^ ]|[^ ][^3]|[^ ]{3,}|[^ ]))* *$
regex that match every valid code to print Hello World! once
(would have been easier if you put break after printing
what is a good practice to create a frozenset with 1 element
frozenset((element,)) works fine i would imagine
i think the same
frozenset({element}) might be clearer but it will be ever so slightly slower also
so i wouldnt in a tight loop
i think i prefer the tuple option]
!e
def foo(val: int):
def next():
nonlocal val
val += 1
def actual() -> int:
nonlocal val
return val
return next, actual
plus_one, current = foo(0)
print(current())
plus_one()
print(current())
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0
002 | 1
#bot-commands
that is on-topic, imo
How is that eso tho π
Doing weird things?
Ok, maybe I am weird but I don't think that's weird π
You don't need the nonlocal in actual
Or wait, maybe you do?
!e
a=5
o="+"
b=5
def calc(a,b,o):
import os,sys,time
if o not in ['+','-',':','x','^']:return
ex="{0}{1}{2}".format("{}".format(a),o,"{}".format(b)).replace(':','/').replace('x','*').replace('^','**')
for i in "{}".format(a):
if i.isdigit():continue
return
for i in "{}".format(b):
if i.isdigit():continue
return
if o=="/" and b==0:raise ZeroDivisionError
with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
os.system("{0} {1}".format(sys.executable,"{}\\exec.py".format(os.getcwd())))
with open("{}\\result".format(os.getcwd()),"r") as file:r=file.read()
os.remove("{}\\result".format(os.getcwd()))
return r
print(calc(a,b,o))
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 20, in <module>
003 | print(calc(a,b,o))
004 | ^^^^^^^^^^^
005 | File "/home/main.py", line 15, in calc
006 | with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
007 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
008 | OSError: [Errno 30] Read-only file system: '/home\\exec.py'
tell me you use windows without telling me you use windows 
lul
damn
!epy import os; os.mknod("newfile.txt")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
newfile.txt
[Empty]
!e
import os; os.mknod("newfile.ktx")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Files with disallowed extensions can't be uploaded: .ktx
!e
import os; os.mknod("newfile.lbx")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Files with disallowed extensions can't be uploaded: .lbx
Found on another server: how to reverse a list in python
l = [2, 9, 5, 1, 4, 1, 3]
from uu import*
Error.__lt__=DeprecationWarning
l.sort(key=Error)
print(l)
Also code golfing challenge: write the shortest code which defines a function that returns that returns the first (the most significant) digit of the given number in base 10. (So if given 789, it should return 7)
lambda a:f"{a}"[0]
with handling negative:
lambda a:f"{abs(a)}"[0]
list(reversed(l))
there is something shorter than lambda a:f"{a}"[0] π
do you have to handle negative?
no
would you mind showing answer in spoiler
I can't just reveal an answer immediately, that would ruin the fun :)
I mean in spoiler, so people can see if they don't want to play, and just not open if they want to
is the "given number" an integer
yes
its not shorter but i got a nice solution with fstrings
||```py
lambda a:f"{a!s:.1}"
you're on the right track
wait
OH i think i got it
||```py
"{0!s:.1}".format
actually that depends on what you mean by "define a function"
but its a neat trick lol
there's something even better
hm
you've found like 2/3 of the tricks
yep
nice
thats my solution
fun lil challenge
leftover from C
That's not defining a function π
||f="%.1s".__mod__||
i need 128972981 gb ram to maintain my os
Otherway: ImportError: DLL load failed:
hi hi, need some help with making a slight pooppost.
I like the dad joke "to be frank.... id have to change my name"
so I wanted to do a function that takes an object and returns an exact copy with an additional class called frank added to it
here is my code so far:
class a:
pass
class b(a):
pass
def create_frank(class_list):
class frank: pass
frank.__bases__ = class_list
return frank
def be_frank(inp):
ret = create_frank(inp.__class__.__bases__)
for i in dir(inp):
print(i)
try:
setattr(ret, i, getattr(inp, i))
except:
print("failed", i)
return ret
print(be_frank(b()))
but im getting a weird error about some deallocator issue, can someone help?
!e ```py
class a:
pass
class b(a):
pass
def create_frank(class_list):
class frank(*class_list): pass
return frank
def be_frank(inp):
ret = create_frank(inp.class.bases)
for i in dir(inp):
try:
setattr(ret, i, getattr(inp, i))
except:
print("failed", i)
return ret
print(be_frank(b()))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | failed __class__
002 | failed __dict__
003 | <class '__main__.create_frank.<locals>.frank'>
although i don't think you should be returning a class from passing an instance-
oops, meant to add parans, after the call of create frank
people named frank:
its an expression thats callable
what definition would you use
since you didnt give the function a name either lol
technically i created a function also
a new callable object was generated
bound method :3
how are you meant to call it?
cant do it as an expression because you're allowing def
and you didnt assign the lambda a name
(define a function
never said it have to be used as long as it is valid
and you said define so I think it must have to use lambda/def
(unless my defintion of define a function is wrong, if so, please correct me
i would say 'define' means create here
normally it means 'create and give a name'
but you didnt give yours a name so i followed your usage
Β―_(γ)_/Β―
well for me, that should more like get a callable than defining it
(don't need name, who cares name lul
well you need a name to call it
unless you're calling it in in the same expression that generates it
which you cant do with def
but you included def in your definition here
Well, because from definition, only those 2 can be considered as define (I am not saying I am correct)
!e
from functools import reduce; from operator import or_ ;from itertools import starmap; this = that = or_func = something_else = lambda: True
print('hi ppl (:' * int(reduce(or_,
starmap(lambda lol2, more_lol: lol2 and more_lol, # yes i purpusfully put DoYouThinkThisCodeIsNice like that ππππ
zip([this(), that(), or_func(), something_else()], [that(), or_func(), something_else(), this()])
))) if any([that(), or_func(), something_else(), this()]) else '')```
:white_check_mark: Your 3.12 eval job has completed with return code 0.
hi ppl (:
:incoming_envelope: :ok_hand: applied timeout to @sick hound until <t:1723681699:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
i am looking for scrapping and bot developer
if you are high skilled dev, plz dm. I want high skill. if you can't provide me your recent similar project or experinece, don't waste time
this is will be long term relationship
this server ain't the place to find workers, and #esoteric-python especially is not
we will make your codebase gross 
we will replace sorted(s) with dir(type('',(),{'__dir__':lambda _:s})())
imagine show no other activity that just advertising and expect high skill people to dm him π
probably asking for it for free too
Hi,
I am working on a small project related to RAG and am stuck (Apparently cuz I don't know much)
I used mxbai-embed-large as embeddings and Chroma db as Vector store all goes well to this point.
Issue: When I try to retrieve data with similarity threshold it returns 0 docs and without threshold and k it always returns 4 docs no matter the query.
What is it that I am doing wrong?
Here my Code:
Vector Store Creation File:
# Load Docs and then store embeddings in the Chroma DB
from langchain_community.embeddings import OllamaEmbeddings
from langchain_community.document_loaders import PyMuPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_chroma import Chroma
embeddings = OllamaEmbeddings(
base_url="http://43.204.231.131:11434",
model="mxbai-embed-large",
)
loader = PyMuPDFLoader("./data/aliceShort.pdf")
data = loader.load()
# print(len(data))
text_splitter = RecursiveCharacterTextSplitter(
# Set a really small chunk size, just to show.
chunk_size=300,
chunk_overlap=100,
length_function=len,
add_start_index=True,
)
chunks = text_splitter.split_documents(data)
print(f"Split {len(data)} documents into {len(chunks)} chunks.")
db = Chroma.from_documents(chunks, embeddings,persist_directory="./chroma_langchain_db")
query = "Who is Alice?"
docs = db.similarity_search(query)
print(docs[0].page_content)
Query File:
from langchain_community.embeddings import OllamaEmbeddings
from langchain_chroma import Chroma
embeddings = OllamaEmbeddings(
base_url="http://65.2.37.27:11434",
model="mxbai-embed-large",
)
db = Chroma(persist_directory="./chroma_langchain_db", embedding_function=embeddings)
query_text="Who is Alice?"
retriever = db.as_retriever(
search_type="similarity_score_threshold", search_kwargs={"score_threshold": 0.1})
docs = retriever.invoke(query_text)
print(len(docs))
this is probably not the right channel to ask such questions
you will not get any useful answers here
ok can you tell me where should I post it?
any other community or channel
#data-science-and-ml - this is the best choice, I think
and you always can open your help thread: #βο½how-to-get-help
Thanks dude π
Anyone had problems with pickle files getting corrupted? Im just reading them , but every couple months one (out of 3K) gets corrupted, almost always getting truncated. It never throws an error just silently delivers less data than it should. Windows machine. Also is this the right channel for that question
sounds like you have a race condition
Hey guys, I've a question.
Usually we, the developers use git for committing our code changes and creating new branches for features and merging it with an existing branch.
So whenever I push my code to repo ( azure DevOps git repo) I need to some how generate a report like release notes.
How do I do that automatically? I've seen some people typing the commits manually in word document and making release notes.
why did you decide to ask here?
didn't we decide to give people most cursed solution normal problems they ask here?
im too tired today, sorry :(
ΞΞΞ¨ = lambda Ξ·: (setattr(__import__("builtins"), 'Ξ', (Ξ := Ξ+1) if Ξ· == "Bell" else 0) or (
(print("You Won Β£5"), setattr(__import__("builtins"), 'Ξ³', Ξ³+5), setattr(__import__("builtins"), 'Ξ', 0)) if Ξ == 3 else None) or (
setattr(__import__("builtins"), 'Ξ¨', (Ξ¨ := Ξ¨+1) if Ξ· == "Skull" else 0) or (
(print("You Lost Everything!"), setattr(__import__("builtins"), 'Ξ³', 0), setattr(__import__("builtins"), 'Ξ¨', 0)) if Ξ¨ == 3 else (
print("You Lost Β£1"), setattr(__import__("builtins"), 'Ξ³', Ξ³-1), print(f"Balance: {Ξ³:.2f}") if Ξ¨ == 2 else None)))
``` i need more esotericness smhw
its too basic to submit as homework
set it to __loader__ instead of builtins
oh it got declined π
anyway
ΞΞΞ¨ = lambda Ξ·: (setattr(__loader__, 'Ξ', +(Ξ· == "Bell" and (Ξ := Ξ+1))) or (
(print("You Won Β£5"), setattr(__loader__, 'Ξ³', Ξ³+5), setattr(__loader__, 'Ξ', 0)) if Ξ == 3 else None) or (
setattr(__loader__, 'Ξ¨', +(Ξ· == "Skull" and (Ξ¨ := Ξ¨+1))) or (Ξ¨ == 3 and
(print("You Lost Everything!"), setattr(__loader__, 'Ξ³', 0), setattr(__loader__, 'Ξ¨', 0)) or (
print("You Lost Β£1"), setattr(__loader__, 'Ξ³', Ξ³-1), print(end=f"Balance: {Ξ³:.2f}\n"*(Ξ¨ == 2)))))
i feel like i can golf this further but im not seeing how (aim is to solve problem in minimal bytes)
"Line 1: An integer n for the number of integers.
Line 2: Integers of the list
Sum of resulted list with odds multiplied by 5 and evens by 3."
_,*x=map(int,open(0))
print(sum(map(lambda i:i*(3,5)[i%2],x)))
i*(3,5)[i%2] β¦ i*3+(i&1)*2
does that work
print(sum([(v:=int(x))*(3,5)[v%2]for x in open(0)][1:]))
is that valid? I haven't used open(0) much but it's 6b less
yeah that should be equivalent
it probably would've, times up tho i dont have the test cases anymore lol. i was looking for something like that, but i was trying to do something like i*(2*(i%2+1)+1) or something
ended up being longer
uh open(0) is finicky as hell im not sure it likes being "directly" iterated like this
it mightve worked though
isn't that what sum is doing
should be -1B with my shortening applied
when it runs the map calls
its petfectly fine with it
perfectly
sum would be iterating over the map, map would be reading the file object once per call
so not really
the second object in map is iterated over
open(..) is a line iterator
but if it works it works
wdym by finicky btw
historically in these kinds of problems it just has not worked in some cases for me
it has problems being read all at once in certain ways
when you get this knee deep in cursed golf you just have to accept that it's weird and borkey
i really don't know why honestly
its just equivalent to an iterator over sys.stdin.readlines()
print(sum([(v:=int(x))*3+2*(v&1)for x in open(0)][1:]))
i immediately found a shorter way to do this but this was a funny solution for another challenge while it lasted:
s,r,i=input(),'',1
exec('r+=(s[0].lower(),s[0].upper())[i];i=(i+s[0].isalpha())%2;s=s[1:];'*len(s))
print(r)
lol nice
print(sum([(v:=int(x))*7^2<<v%2for x in open(0)][1:]))
oh fuck
the operator precedence was fine until I added the * π
7^2<<v%2 gives 3 and 5
but since hecking * is higher than all of them but mod it ruins it 
is that a ^ π
last time I saw one in python was a year ago
xor operator
uh ```py
print(sum((v:=int(x))(3+v%22)for x in[open(0)][1:]))
print(sum((v:=int(x))3+v%2v2for x in[open(0)][1:]))
print(sum(int(x)(3+int(x)%2*2)for x in[*open(0)][1:]))
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically have non-negative integer values, with negative values being reserved to indicate "no value" or error con...
ah, nice golf
it's in the original one :p
noticed, but just idk how it work
until that
Ah, I was sure I could save at least a byte on the splicing π
_,*o=map(int,open(0));print(sum(v*(3+v%2*2)for v in o))
Fun fact, open(0) and 0 will close the repl if you run it in the interactive terminal
Weird, why is that?
Because when the file object is freed, it closes the input file descriptor
Which means python gets the EOF error when trying to read the next character from the user
So it assumes the user hit ctrl-D
And that's how you would exit the repl I'm assuming
doesn't work for me D:
open(0).close() would
eh i wonder what kind of REPL that is ```pycon
open(0).close()
2 + 5
7
3
3
do i have to use linux to get that bug?
Probably, also on mac
Oh yea Unix only, I think on windows you can't close the stdin file handle
!e
a=5
o="+"
b=5
def calc(a,b,o):
import os,sys,time
if o not in ['+','-',':','x','^']:return
ex="{0}{1}{2}".format("{}".format(a),o,"{}".format(b)).replace(':','/').replace('x','*').replace('^','**')
for i in "{}".format(a):
if i.isdigit():continue
return
for i in "{}".format(b):
if i.isdigit():continue
return
if o=="/" and b==0:raise ZeroDivisionError
with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
os.system("{0} {1}".format(sys.executable,"{}\\exec.py".format(os.getcwd())))
with open("{}\\result".format(os.getcwd()),"r") as file:r=file.read()
os.remove("{}\\result".format(os.getcwd()))
return r
print(calc(a,b,o))
```print#export(:``walheck:)
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 20, in <module>
003 | print(calc(a,b,o))
004 | ^^^^^^^^^^^
005 | File "/home/main.py", line 15, in calc
006 | with open("{}\\exec.py".format(os.getcwd()),"w") as file:file.write("with open('{0}\\\\result','w') as file:file.write(str({1}))\nimport os\nos.remove(__file__)".format("\\\\".join(os.getcwd().split('\\')),ex))
007 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
008 | OSError: [Errno 30] Read-only file system: '/home\\exec.py'
!e
globals().update(vars(__import__("ast")));exec(compile(fix_missing_locations(Module([FunctionDef('say_hello',arguments(posonlyargs=[],args=[],kwonlyargs=[],kw_defaults=[],defaults=[]),[Expr(Call(Name('print',Load()),[Constant('Hello!')],[]))],[]),Expr(Call(Name('say_hello',Load()),[],[]))],[])),"<string>","exec"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
Hello!
Some dumbass on my server was ranting about whitespace
No whitespace, perfectly legible
if βs/\n/;/ then yeah
newlines aren't real whitespace but fine π
lol yeah the whole 'is a newline a whitespace character' is a divisive topic
but RFC 2822 refers to LF and CR as whitespace, so i tend to follow that
mans citing rfcs now
i was just kidding, of course it's whitespace π
trivial whitespace tho
in terms of how hard it is to replace
i do agree that there should be some distinction between newlines and usual whitespace, since newline also resets the position horizontally of the cursor
whereas \hspace and \vspace just move it orthogonally
true
I just wanted to write from ast import * without spaces 
Do you suppose there is a difference between that and globals().update(vars(__import__("ast")))? π€
from ... import * type imports respect the module's __dir__ attribute, if it has one
i dont think vars does, but i could be wrong
Ah, __all__ too, yeah
How do you do a spaceless star import with importlib?
Apart from doing what I did and just replacing the __import__
sorry, i was unclear
i meant using __import__ (which is importlib.__import__) and manually emulating the from import behaviour
Wanna write it out? π
i do want to, but dont think i can rn (am on mobile currently)
perhaps in a few hours once i get home
Thats for printing hello???? xD
0009..000D ; White_Space # Cc [5]
i agree that its whitespace! but many argue that a newline is not
Man I was kidding about that 
No, it's for defining a function that prints hello and calling the function 
Wow! Thats really too much for a beginner like me!
newline is whitespace, but not space
that's how i think it is
It is, when ill know python good ill try writing some cursed stuff too
well, this is the curse jail, all curse python code should only be shared here without spoiler π
i agree; its whitespace but not white space
in my mind, whitespace ::= white-space | "\n" | "\r" | "\f" | (etc.)
That's the spirit π―
it also doesn't import names that start with _ by default
is this oneliners?
is that gpt generated?
Doubt AI could generate that
they can generate some crazy stuff so xd
try out yourself
like
explain to ai how to do something similar
and see if it could do anything remotely similar to this
Lol good luck with that
God damn
!e
globals().update(vars(__import__("ast")));exec(compile(fix_missing_locations(Module([FunctionDef(name='fibonacci',args=arguments(posonlyargs=[],args=[arg(arg='n',annotation=None)],kwonlyargs=[],kw_defaults=[],defaults=[]),body=[If(test=Compare(left=Name(id='n',ctx=Load()),ops=[LtE()],comparators=[Constant(value=1)]),body=[Return(Name(id='n',ctx=Load()))],orelse=[]),Return(BinOp(left=Call(func=Name(id='fibonacci',ctx=Load()),args=[BinOp(left=Name(id='n',ctx=Load()),op=Sub(),right=Constant(value=1))],keywords=[]),op=Add(),right=Call(func=Name(id='fibonacci',ctx=Load()),args=[BinOp(left=Name(id='n',ctx=Load()),op=Sub(),right=Constant(value=2))],keywords=[])))],decorator_list=[]),Assign(targets=[Name(id='result',ctx=Store())],value=Call(func=Name(id='fibonacci',ctx=Load()),args=[Constant(value=7)],keywords=[])),Expr(Call(func=Name(id='print',ctx=Load()),args=[Name(id='result',ctx=Load())],keywords=[]))],[])),"<string>","exec"))
:white_check_mark: Your 3.12 eval job has completed with return code 0.
13
lol
that's literally just using the well documented ast module to create a normal fib
Sure but I would've expected chatgpt to screw it up somehow
Im kinda lost
Which is the correct channel for Machine Learning stuff?
Ok we are done
I would expect it screw up quite a lot because it's not normal code style -> lack of example and also too messy
chatgpt screws up normal code so by my logic it won't screw up (or at least will screw up less on) weird code
π
And also, I guess, esoteric content is harder for AI to scrape?
what if AI speaks in esoteric
explains why it kind of sucks in normal code
but sort of works in the above example
less in quantity, less uniform in task, more entropy in code, tends to break locality of logic
(if it could have scrape more, the quality of AI for code generation is most likely get lower lul
You're saying we should get gpt to produce the most cursed code possible and flood the internet with it? 
π
real??????
Data poisoning is moral and effective.
I didn't said that
Oh, no, right, of course not π
I definitely don't endorse it and haven't already started working on it either π
None of us are organising in the underground with the goal to kill all AI π
π
Well, only for python code generation
Or a more quantity of different variety of esoteric code probably harm more than repeated same content ig
I wonder how much esoteric code can AI generate?
Well, certainly not multi megabytes file
to be fair, GPT was likely trained on syntax trees specifically because it needs to rewrite code, and it would be easier to teach a model to round trip then it would be to get it to work inplace
I'm fairly certain it doesn't rewrite code by way of syntax trees but its all too complicated to understand anyways
new quest: train a LLM to make esoteric code
You don't need to train it, you can just ask gpt
Here's your new new quest: write code so esoteric that gpt doesn't understand what it does
I wouldn't belief it would be specifically being taught on syntax tree instead of just being feed with random internet data
Consider python is just one of the many languages in programming, which is just small aspect of the variety of topic in the world
I am not surprised that it can spit out valid syntax trees
it is not a complicated transformation, you just encode the same meaning with different set of tokens
doesn't it just predict what comes next..?
yep
large language models are good at language stuff, for example translating from one language to another
py->ast falls into "translation" category imo
Well natural languages and programming languages are fundamentally quite different I think
And LLMs are much better at natural languages than anything else (by the way I thought this was one of the off-topic channels, oops)
is there any way to run a function using decorators without a space?
@eval
@input
class x:0
there is still space when define a class
you could use a tab π
i mean whitespace in here
nope, decorators only apply to def ... and class ... according to the grammar
the newline after the decorator is mandatory too
new line is ok, the problem is the whitespace when define the class
From the grammar ```
decorators: ('@' named_expression NEWLINE )+
Class definitions
-----------------
class_def:
| decorators class_def_raw
| class_def_raw
class_def_raw:
| 'class' NAME [type_params] ['(' [arguments] ')' ] ':' block
Function definitions
--------------------
function_def:
| decorators function_def_raw
| function_def_raw
function_def_raw:
| 'def' NAME [type_params] '(' [params] ')' ['->' expression ] ':' [func_type_comment] block
| ASYNC 'def' NAME [type_params] '(' [params] ')' ['->' expression ] ':' [func_type_comment] block
there are no mentions of decorators anywhere else
and they can only be used with 'def' NAME ... and 'class' NAME ...
so unless you can separate a keyword and identifier without a space it's impossible
I see, thx btw!
where is the tab for helping
Ok so when you call a class method, for example, obj.do_stuff(), by default:
- The interpreter checks
obj.__dict__and if finds the attribute there, then it returns the value, and assuming its a callable, it does not touch its__self__attribute
2: The interpreter checksobj.__class__.__dict__and if finds the attribute there, then it returns the value, and assuming its a callable, it does set its__self__attribute toobj
3: And if everything fails then __getattr__ happens
But, is there any way to dinamically define instance method objects in __getattr__ so that their __self__ parameter is set to obj when __getattr__ is called?
idk if im making any sense
and obviously i see 0 use cases for this but we`re here in esoteric for a reason lmao
Sure, you can put partials in there, or even real method objects.
Also, the process you described is a simplification, there's also descriptors which are looked up before even looking in __dict__. (I also assume by "class method" you mean instance method.)
!e
class X:
def __getattr__(self, attr):
def fakemethod(name):
print(attr, "says", name)
return fakemethod
x = X()
x.foo("bar")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
foo says bar