#esoteric-python
1 messages · Page 39 of 1
should probably have options to handle different output codecs
we might want to output in EBCDIC
etc.
and it would be nice to be able to read options from a file
-o FILENAME / --output FILENAME would be nice
ooo true
... if we're doing -o | --output for stdout we should probably have a -i | --input for stdin
just so that it matches
oh and there should be an option for the output to be gzipped
It should also be possible to output a few different formats, pdfs, png, etc
For completeness lmao
of course, logging and warnings
yep
btw seperator should be separator if im not crazy
add runtime type checks, because we cant trust type annotations
dont use asserts, they are removed in release mode
unit tests
add possibility to print hello world in different formats: ```
Hello, world!
Hello, world
hello, World
hello, world
hello world
hello_world
helloworld
add options for other languages like `--lang=en` or `--lang=ru`
This should fall back to the LC_*/LANG env vars
Also, it should of course look at config files in various locations
you probably should catch other exceptions, not only BaseException
for example, you can print something to stderr if stdout died for some reason
.config/helloworldrc, .helloworldrc, and falling back to the system-wide /etc/helloworldrc
there is no error handling outside of main() in if __name__ code - we cant be sure that main() doesnt throw anything
(come to think of it, these should probably be yaml files)
yaml file that uses json syntax - for robustness
if there is no yaml parser available, we can fall back to json parser
add option to enable colored output (and also look at envvars to determine if colors are available)
if you decided to use from __future__ import print_function, then consider using u prefix for strings: u"Hello, world!" instead of "Hello, world!"
I wonder how many different data file encodings you could possibly stuff into one file, for maximum parse redundancy. also remember to throw in an ast.literal_eval
you are correct
no no no
it should use the XDG Base Directory Specification
specifically it should use the environment variables $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS
but it needs to fall back to $HOME/.config and /etc/xdg respectively if those variables are unset or empty
i don't know what to test this with but here's 117b ```py
import sys
for s in sys.argv[1:]:b=1;print(s+(str(j:=sum(int(c)(b:=b+1)for c in s.replace("-",""))%11))(j>9)or"X"))
109b ```py
import sys
for s in sys.argv[1:]:b=1;print(s+(str(j:=sum(int(c)(b:=b+1)for c in s if'-'<c)%11))(j>9)or"X"))
Doesn't work. This calculates the ISBN checksum, I believe
Calling it with 123456789 987654321 as arguments should print
123456789X
9876543210
Fixed your code though, still 109 bytes:
import sys
for s in sys.argv[1:]:b=0;print(s+(str(j:=sum(int(c)*(b:=b+1)for c in s if'-'<c)%11)*(j<=9)or"X"))
why not do <10 (108 bytes) ```py
import sys
for s in sys.argv[1:]:b=0;print(s+(str(j:=sum(int(c)(b:=b+1)for c in s if'-'<c)%11)(j<10)or"X"))
Still 109 bytes, by my count. Makes sense, if you're replacing =9 by 10.
>>> x=list(range(5))
>>> for x[-1] in x:
... print(x, x[-1])
...
[0, 1, 2, 3, 0] 0
[0, 1, 2, 3, 1] 1
[0, 1, 2, 3, 2] 2
[0, 1, 2, 3, 3] 3
[0, 1, 2, 3, 3] 3
💦
This Feels So Cursed
[print(*row) for row in list(zip(*list(permutations({"V", "L", "R", "G"}))))] nah, this is cursed, it gets the permutations of the pinouts of a 4 pole 3.5mm jack to component AV connector, transposes them, and prints them out, all in one line 
well,, ignoring the line you need to import itertools.permutations atleast
Yeah, No... That's Like Most Normal Python Code
If You Had Done It Without Import Then Yes
You can remove both calls to list()
tru,, that was a relic of my debugging before i made it into a oneliner
heh
my brain just exploded
Btw print In List Comprehension? Bruh
for row in list(zip(*list(permutations({"V", "L", "R", "G"})))): print(*row)?
yeah, less characters in a list comp
To Golf It: for row in list(zip(*list(__import__('itertools').permutations({"V", "L", "R", "G"})))): print(*row)
isnt it?
True, But Isnt That More Memory Used?
Yes, print Doesnt Return Anything So Its None, But [None] * n < 0
I Think
Correct Me If Im Wrong 😅
i would assume it optimizes the Nones out, since, atleast if ur not using ipython, its not storing it anywhere??
Permutations not permutations, product for even longer. I used it to generate a 33k char long regex for AoC day 3 #1180738420272799814 message
lmfao
for row in zip(*__import__('itertools').permutations("VLRG")):print(*row)
ey guys, i just made a badass code obfuscator, for now it does stuff like this, i am working on all the cool thingys, such as 1 liners and stuff
i am working on it, i'll post the project here after i finish it so you guys can take a look
A helpful feature, Find and replace 🙂
*map(print,iterable), is another option, but it won't work here because you need to unpack as well
for r in zip(*__import__('itertools').permutations("VLRG")): print(*r)
import itertools as x;x.permutations
__import__('itertools').permutations
import itertools as x;x.permutations
__import__('itertools').permutations
from itertools import*;permutations
holy, okay, that is sick
chat seems pretty dead
this is unfinishedd :(
i still have soo much things to fix
golf this more?
import sys
for i in sys.argv[1:]:
j=0;f=.1
while f%1:exec("j+=1;f=j*"+i)
print(f"{int(f)}/{j}")```
reduces argument a/b to its simplest form
unpacking into a set
the docs show all you can do
it works for a pc to another but when i try to make it as an apk to use it in my phone it's not working.
i'm using python(kivy, paramiko). please help me!
i don't understand i puted .spec files with requirements: python3, kivy, paramiko
https://github.com/herzSaifElarbi/pcController.git
i think this is the wrong channel for you
i've done this challenge before
wait
!e
from types import SimpleNamespace
n = n.v = n.e = n.a = n.y = n.g = n.p = n.o = n.r = n.u = n.i = n.n = n._ = SimpleNamespace()
print(n.e.v.e.r._.g.o.n.n.a._.g.i.v.e._.y.o.u._.u.p is n)
@digital mesa :white_check_mark: Your 3.12 eval job has completed with return code 0.
True
what the fuck
thanks
from types import SimpleNamespace
n = n.v = n.e = n.a = n.y = n.g = n.p = n.o = n.r = n.u = n.i = n.n = n.l = n.t = n.d = n.w = n._ = SimpleNamespace()
print(bool(n.e.v.e.r._.g.o.n.n.a._.g.i.v.e._.y.o.u._.u.p and n.e.v.e.r._.g.o.n.n.a._.l.e.t._.y.o.u._.d.o.w.n))```
glad to inspire
from types import SimpleNamespace
n = n.v = n.e = n.a = n.y = n.g = n.p = n.o = n.r = n.u = n.i = n.n = n.l = n.t = n.d = n.w = n.ᅠ= SimpleNamespace()
print(bool(n.e.v.e.r.ᅠ.g.o.n.n.a.ᅠ.g.i.v.e.ᅠ.y.o.u.ᅠ.u.p and n.e.v.e.r.ᅠ.g.o.n.n.a.ᅠ.l.e.t.ᅠ.y.o.u.ᅠ.d.o.w.n))
forgot to eval
!e ```py
from types import SimpleNamespace
n = n.v = n.e = n.a = n.y = n.g = n.p = n.o = n.r = n.u = n.i = n.n = n.l = n.t = n.d = n.w = n.ᅠ= SimpleNamespace()
print(bool(n.e.v.e.r.ᅠ.g.o.n.n.a.ᅠ.g.i.v.e.ᅠ.y.o.u.ᅠ.u.p and n.e.v.e.r.ᅠ.g.o.n.n.a.ᅠ.l.e.t.ᅠ.y.o.u.ᅠ.d.o.w.n))
@quartz wave :white_check_mark: Your 3.12 eval job has completed with return code 0.
True
!e
from types import SimpleNamespace
n = n.v = n.e = n.a = n.y = n.g = n.p = n.o = n.r = n.u = n.i = n.n = n.l = n.t = n.d = n.w = n.ᅠ= SimpleNamespace()
am_i_gonna = bool
print(am_i_gonna(n.e.v.e.r.ᅠ.g.o.n.n.a.ᅠ.g.i.v.e.ᅠ.y.o.u.ᅠ.u.p and n.e.v.e.r.ᅠ.g.o.n.n.a.ᅠ.l.e.t.ᅠ.y.o.u.ᅠ.d.o.w.n))```
@unique heath :white_check_mark: Your 3.12 eval job has completed with return code 0.
True
oh you sly dog
using a character that looks like space
:3
!e ```py
from types import SimpleNamespace
n = n.v = n.e = n.a = n.y = n.g = n.p = n.o = n.r = n.u = n.i = n.n = n.l = n.t = n.d = n.w = n.rᅠg = n.aᅠg = n.eᅠy = n.uᅠu = n.aᅠl = n.tᅠy = n.uᅠd = SimpleNamespace()
amᅠiᅠgonna = bool
print(amᅠiᅠgonna(n.e.v.e.rᅠg.o.n.n.aᅠg.i.v.eᅠy.o.uᅠu.p and n.e.v.e.rᅠg.o.n.n.aᅠl.e.tᅠy.o.uᅠd.o.w.n))
@quartz wave :white_check_mark: Your 3.12 eval job has completed with return code 0.
True
slie dogge
Silly doge
!e ```py
neverᅠgonnaᅠgiveᅠyouᅠup = neverᅠgonnaᅠletᅠyouᅠdown = neverᅠgonnaᅠrunᅠaround = desertᅠyou = True
print(neverᅠgonnaᅠgiveᅠyouᅠup, neverᅠgonnaᅠletᅠyouᅠdown, neverᅠgonnaᅠrunᅠaround and desertᅠyou)
@quartz wave :white_check_mark: Your 3.12 eval job has completed with return code 0.
True True True
amazing
lmao
can you explain how it accepts spaces? are those some other unicode chars instead of space?
yeah, its not actual spaces
0o no
pls don't be the same idea I've been working on
i feel like we all know the idea
I have a working copy of my idea but idk if I should take the time to make it better...
the esopy hive mind
I'll just post it so I can be first in case it's the same idea as someone else
!e
class Zen(int):
def __getattr__(self, *_):
return self
Beautifulᅠisᅠbetterᅠthanᅠugly = refuseᅠtheᅠtemptationᅠtoᅠguess = andᅠpreferablyᅠonlyᅠone = obviousᅠwayᅠtoᅠdoᅠit = right = now = itᅠisᅠaᅠbadᅠidea = itᅠmayᅠbeᅠaᅠgoodᅠidea = letᅠusᅠdoᅠmoreᅠofᅠthose = Zen()
(
Beautifulᅠisᅠbetterᅠthanᅠugly.
Explicitᅠisᅠbetterᅠthanᅠimplicit.
Simpleᅠisᅠbetterᅠthanᅠcomplex.
Complexᅠisᅠbetterᅠthanᅠcomplicated.
Flatᅠisᅠbetterᅠthanᅠnested.
Sparseᅠisᅠbetterᅠthanᅠdense.
Readabilityᅠcounts.
Specialᅠcasesᅠareᅠnotᅠspecialᅠenoughᅠtoᅠbreakᅠtheᅠrules.
Althoughᅠpracticalityᅠbeatsᅠpurity.
Errorsᅠshouldᅠneverᅠpassᅠsilently.
Unlessᅠexplicitlyᅠsilenced.
Inᅠtheᅠfaceᅠofᅠambiguity, refuseᅠtheᅠtemptationᅠtoᅠguess.
Thereᅠshouldᅠbeᅠone-- andᅠpreferablyᅠonlyᅠone --obviousᅠwayᅠtoᅠdoᅠit.
AlthoughᅠthatᅠwayᅠmayᅠnotᅠbeᅠobviousᅠatᅠfirstᅠunlessᅠyouᅠareᅠDutch.
Nowᅠisᅠbetterᅠthanᅠnever.
Althoughᅠneverᅠisᅠoftenᅠbetterᅠthan *right* now.
Ifᅠtheᅠimplementationᅠisᅠhardᅠtoᅠexplain, itᅠisᅠaᅠbadᅠidea.
Ifᅠtheᅠimplementationᅠisᅠeasyᅠtoᅠexplain, itᅠmayᅠbeᅠaᅠgoodᅠidea.
Namespacesᅠareᅠoneᅠhonkingᅠgreatᅠidea -- letᅠusᅠdoᅠmoreᅠofᅠthose.ᅠ
)
@digital mesa :warning: Your 3.12 eval job has completed with return code 0.
[No output]
I realized that I could've made all those is s and the and work normally, by defining more variables
so, was it the same idea? 😄
that was not what i tought it was
ok well now I'm wondering what your idea is
replacing all _ with the funny space
image = \
\
\
\
\
pygame.transform.scale(image, (30,30))
``` 👍
nah thats not what I am gonna do
ok
mfw each file in this project has more loc than my biggest project ever
writing the zen of python without following the zen of python
Call that Nez
real
I think I may have asked about it before here but found a better solution elsewhere
!pep 18
PEP 18 does not exist.
!pep 8

it's possible to follow pep 8 and still be esoteric
what happened to pep18 💀
what you guys think? i am still working on the obfuscation of code, just added random comments in random lines
that type of obfuscation is not very hard to deal with, just annoying
@versed eagle i know i know, just doing some silly stuff, i am planning on converting code into images and adding workflow obfuscation and all those thingys
i mean, i am doing a program to do all of that
i pass the code as the input, and the output is that annoying thing
for now, it just changes variable names, functions, classes, and params + adds comments
does it remove comments?
not yet, i will add it in the next update tho, i am working on adding random if statements
now it removes them!
line_without_comments = re.sub(r'#.*', '', line)
that funny line removes them for every single line
Did you make sure to not do that inside string literals?
print("""
# <- that shouldn't be removed """)
i did not let me fix that real quick
got it
Input:
a = "#Zxc"
print(a) #zxcased
Output:
# Why was this done this way? line 122
IOO0OOO0O00OO00O0O0 = "#Zxc"
print(IOO0OOO0O00OO00O0O0)
IMO the easiest way to remove comments is to code=ast.unparse(ast.parse(code))
I wonder if you could do some fancy NLP to make the names refer to a correct-seeming wrong name, rather than just a clearly meaningless one.
I wonder how that would look
for now this is the function that gets the names
it doesnt even take account of how many vars, funcs, etc, that are in the program, and it computes literally all the possibilities with those letters, based on the obfus_chars number
it is so bad, i know ahahahah
you mean like, doing a criteria based on the context of the variables/class... ?
i've seen this exact obfuscator online somewhere
the IO0O0O shit
it just changes variables names and takes off comments
I will try to use chatgpt api, taking inspiration by this vid https://www.youtube.com/watch?v=vOkp2PN2S6Q&t=498s
In this project, I employed the use of AI to create a minion twitch streamer that interacts with chat and the game. This project took me about a week to fully create, 3 days of coding and 4 days of editing/gathering footage. I hope you guys all enjoy, the github will be below if you want a look at the code or want to try it out yourself (of cour...
it can take any form it is not that bad,
# Placeholder comment line 112
class IeeSe:
# TODO: Review this later line 178
def __init__(ISMSM, ISMMe, IMMMS):
ISMSM.ISMMe = ISMMe
# This might need refactoring line 224
ISMSM.IMMMS = IMMMS
# Placeholder comment line 112
def ISMeS(ISMSM):
return 'I am an animal named ' + ISMSM.ISMMe
class IMSMe(IeeSe):
def __init__(ISMSM, ISMMe, IMMMS, IeeMe):
super().__init__(ISMMe, IMMMS)
# This part is crucial line 32
ISMSM.IeeMe = IeeMe
def ISMeS(ISMSM):
# This part is crucial line 32
return 'Woof! My ISMMe is ' + ISMSM.ISMMe
def IeMMe():
IMMMe = IMSMe('Rex', 5, 'Golden Retriever')
print(IMMMe.ISMeS())
IMeeM = [1, 2, 3, 4, 5]
IMSMM = sum(IMeeM)
print('Total:', IMSMM)
for num in IMeeM:
# Placeholder comment line 112
if num % 2 == 0:
print(num, 'is even')
# This part is crucial line 32
else:
print(num, 'is odd')
ISMMe = 'Charlie'
# Be careful with this part line 1
IMMMS = 3
ISSSe = IeeSe(ISMMe, IMMMS)
# Magic happens here line 4
print(ISSSe.ISMeS())
# This might need refactoring line 224
if __name__ == '__main__':
IeMMe()
i think you should maybe look into https://docs.python.org/3/library/tokenize.html
thanks for the advice, i will keep it probably in a few days, i have gotten a crazy idea about converting characters into colors and making an image out of those
i just wanna experiment
best of luck with all your testing
this image, is this code
looks sick tbh
piet?
it is basically a 1 to 1, transformation, each letter of a string is given a color, and it loops throught the letter putting a pixel on the screen.
if you read it in reverse, you'll get the whole string
i didn't even know that was a thing AHAHAHA
you could convert every 4 bytes into a pixel value (r/g/b/a)
compreshun
ill keep working on It tomorrow, now i sleep gn everybody
i wish f-strings were the default mode
If you get positive feedback there then you could probably submit a PEP.
that would be a breaking change tho
Breaking changes are made with just about every version.
Admittedly, this change would be more breaking than most, but it certainly wouldn't be the only breaking change.
introducing s-strings, the new way to write curly braces in your strings! What does the "s" stand for, you ask? It stands for string! Say hello to your new friend, string-strings!
print(s"{No interpolation whatsoever!}")
btw you can use {{ inside f-strings to make {
yep
so this should work: ```py
print("{{No interpolation whatsoever!}}")
but did you consider... s-strings? 🫂
lets also add fs-strings, that will enable f-string formatting in s-strings!
or making ` special strings like js
those are with single backticks
i was trying to wrap the backtick with formatting like a but discord did not like it
yeah idk if it's possible
not the "front tick" 💀
`
̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀
!charinfo `
\uff40 : FULLWIDTH GRAVE ACCENT - `
!charinfo ̀
\u0300 : COMBINING GRAVE ACCENT - ̀
this rendered very weirdly
`
̀̀̀
̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀
Normal backtick rendering on phone, what about other dev?
̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀ ̀
what is going on
for me it looks like this
windows, desktop discord app
Works then ig
!raw
message
!raw <message>
Shows information about the raw API response.
Subcommands:
!raw json <message>
Shows information about the raw API response in a copy-pasteable Python format.
Ah rip
You are not allowed to use that command here. Please use the #bot-commands channel instead.
== Raw message ==
`` ` ``
this is how this message looks when i copied it
there is an esopy core developer!
https://discuss.python.org/t/interpret-for-i-in-n-as-for-i-in-range-n-if-n-is-an-int/43457/10
@timber grotto :white_check_mark: Your 3.12 eval job has completed with return code 0.
HELLO
ran my renamer on it ```py
from inspect import currentframe as A
B, C, D, E, F, G, H = (True, False, chr, len, next, str, print)
H(*(D((B << 6) + E(F((I for I, J in A().f_globals.items() if J == K)))) for K in (E, H, 0, 0, 1)), sep=G())
i think it only works with those names
@quartz wave does your renamer handle attributes of custom classes?
maybe, i'm not sure what that means
cuz I can see here it doesn't rename f_globals.items() because A() is from the library but let's say A() is from a class defined in the code, does it know when to rename and when not to?
nope
that's the part I always struggled with so I hoped to gain some insights 😄
it keeps attributes untouched unless they're from a constant
if you want a challenge you should try supporting that
it gets even more complicated when you try to add multi file support so then you need to see which import is from an external dependency or a local file
i'd try keeping a list of classes and their possible attributes but i never really know when those'll change
like someone could do this ```py
class A:
t = 5
exec("class A: pass")
A.t # ?
yeah you have to set some kind of standards for your users, like the use of exec is not supported by the renamer/obfuscator
I guess when you're using the renamer to rename obfuscated files you can't set those kinds of standards
it's supposed to be a deobfuscator but yeah
i think i tried to add special handling to if-else ternaries where walrus assignments are done
what would be the ideal way to know if a class/instance of a class is local or from an external dep
you'd have to build some kind of small interpreter/emulator to follow the types in the code
kind of like how pytype works as well
error?
yes
but a simple AST checker can't figure that out
and even if an exec() call was analyzed i don't think just the name exec would be used
yeah the parameter to exec could also be generated dynamically so it's not possible
you can do a similar trick à la the halting problem
class A:
if not thinks_has_t_attribute(__file__):
t = 0
A.t # If I think it does, it doesn't. If I think it doesn't, it does.
In computability theory, Rice's theorem states that all non-trivial semantic properties of programs are undecidable. A semantic property is one about the program's behavior (for instance, does the program terminate for all inputs), unlike a syntactic property (for instance, does the program contain an if-then-else statement). A property is non-t...
I think I've created the worlds fastest is_even program. Its even multithreaded 🤯
import threading
number = abs(int(input("Number to check: ")))
thread_count = int(input("Thread count: "))
def find_odd_even(number_range):
for i in number_range:
exec(f"if number == {i}:\n print('{'odd' if i % 2 else 'even'}')\n")
for thread_number in range(thread_count):
number_range = range(thread_number, number + 1, thread_count)
thread = threading.Thread(target=lambda: find_odd_even(number_range))
thread.start()
It comes with multiple features.
- Multithreading 🚀
- Supports signed numbers 🤓
- Dynamic scaling ⚖️
- Made in Python 🐍
number = int(input("Number to check: "))
if number & 1:
print("odd")
else:
print("even")
``` even faster program
- Fast
- Doesn't use % because % is slow
- Made in Python
int main() {
int n;
cin >> n;
if (n & 1) cout << "odd";
else cout << "even";
}``` even faster program
- 🚀🚀faster than all 3 previous programs🚀🚀🚀🚀🚀
- 🚀🚀doesnt use the % 🚀🚀🚀🚀🚀🚀because the % is slow🚀🚀🚀
- 🚀🚀🚀🚀made in C++ for extra 🚀 speed🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🌑
- uses less memory
🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
faster :3
if int(input("Number to check")) & 1:
print("odd")
else:
print("even")
cin and cout are very slow for this use case
use unistd.h
wut dat do
read and write
at that point why not just scanf
because scanf is higher level
read and write are C wrappers around syscalls
huh
truffles
truffles
so i just convert that to an int right
oh btw i found a bug
theres no newline
so its incompatible with the python version
who cares about compatibility
in that case just always output odd
who cares about compatibility, right :3
anyways, here
#include <unistd.h>
int main()
{
char c, d;
while (read(0, &c, 1))
{
if (c < '0' || '9' < c) break;
d = c;
}
if (d & 1) write(1, "odd\n", 4);
else write(1, "even\n", 5);
}
becomes faster if you statically link it (&& use lto)
I made a chip8 decompiler fully in python.
That was a joke. This isn't the showcase channel lol
There isn't one as far as I know
Very cool project, though.
chips
!e
a=lambda:__builtins__.__import__('sys').stdout.write((__builtins__.__dir__()[len(__builtins__.__dir__()[++18]+__builtins__.__dir__()[--0])][(0xf-0x1)-int(str('++-+'.replace(*'+1')).replace(*'-0'),len(__build_class__.__dir__()[--0].strip('__'))+0xa-int('1100',2))])+(__build_class__.__dir__()[len(__builtins__.__dir__()[0x86+0xe])+len(__builtins__.__dir__()[-1])])[0xa-0x7]+2*(__builtins__.__dir__()[int("11",len(__builtins__.__dir__()[0xc+0xf]))][0xa-0x8])+(__builtins__.__dir__()[0x86][1])+chr(32)+chr(119)+(__builtins__.__dir__()[0x86][1])+(__builtins__.__dir__()[0xa-0x7][0x7])+(__builtins__.__dir__()[int("11",len(__builtins__.__dir__()[0xc+0xf]))][0xa-0x8])+__builtins__.__dir__()[1][2]);a()
@fluid pumice :white_check_mark: Your 3.12 eval job has completed with return code 0.
hello world
real
++18 --0 💦
Why Is There So Much Obfuscation For No Reason?...
because thats this channel is about?
"esoteric"
Hmmm... True, But Does Obfuscation Count? I Mean Like Keys With Subtraction And Useless ++{number} 🤔
i mean yeah the channel description quite literally says "obfuscation"
and obfuscation comes in many different forms
I Need To Learn To Read Discord Channel Descriptions
anyone got any better solutions to this:
[print(i)for i in range(51)if i.bit_count()&1]```
thats 46 chars and theres solutions down to 40 i been stuck on this one for 2 years
prints numbers from 0-50 that have an odd popcount/bitcount
!e
[print(i)for i in range(51)if i.bit_count()&1]```
@long fulcrum :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 1
002 | 2
003 | 4
004 | 7
005 | 8
006 | 11
007 | 13
008 | 14
009 | 16
010 | 19
011 | 21
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/HUBOOHPOVJNXBSQUMKSFU2YTQU
https://oeis.org/A000069 states that its also numbers of the form m XOR (2*m+1)
but this doesnt work
!e
for i in range(51):
if i^(2*i+1):print(i)```
@long fulcrum :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
006 | 5
007 | 6
008 | 7
009 | 8
010 | 9
011 | 10
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/HX35G5P3TAAABOXLAQORIOOIAQ
!e That does generate the numbers, just not in order py print([i^(2*i+1) for i in range(51)]) print(all(x in [i^(2*i+1) for i in range(51)] for x in [i for i in range(51)if i.bit_count()&1]))
@fleet lintel :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | [1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16, 49, 50, 55, 52, 61, 62, 59, 56, 41, 42, 47, 44, 37, 38, 35, 32, 97, 98, 103, 100, 109, 110, 107, 104, 121, 122, 127, 124, 117, 118, 115, 112, 81, 82, 87]
002 | True
You can also see why that is the case based on this section of the oeis page
Lexicographically earliest sequence of distinct nonnegative integers with no term being the binary exclusive OR of any terms.
the shortest i can get that is 60
[i<51==print(i)for i in sorted([i^2*i+1for i in range(50)])]```
!e you can hard code the number of values you need once sorted, and use a set to sort it (if relying on implementation details is allowed...), though still longer than your original solution
[*map(print,[*{i^2*i+1for i in range(50)}][:26])]
@sudden osprey :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | /home/main.py:1: SyntaxWarning: invalid decimal literal
002 | [*map(print,[*{i^2*i+1for i in range(50)}][:26])]
003 | 1
004 | 2
005 | 4
006 | 7
007 | 8
008 | 11
009 | 13
010 | 14
011 | 16
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/M4552FC6MRPR6A5HZ3M3VSKUVI
its longer than this sadly
cool thing you can do to make your code shorter is this though
[*map(print,[*{i^2*i+1for i in range(50)}][:26])]
*map(print,[*{i^2*i+1for i in range(50)}][:26]),```
how does your code sort the list actually
By putting them in a set. it's an implementation detail of (current) CPython, not entirely sure why it works tbh, possibly something to do with the hash value of the integers
so sorted(i) is the same as {*i}?
For small, positive, integers in current CPython, I think so
It basically sorts them by their hash value (or the last n bits of it). Positive integers hash to themselves. That does mean that if there are gaps, the result isn't necessarily sorted, even for small positive integers.
!e
print({*(1, 8)})
@restive void :white_check_mark: Your 3.12 eval job has completed with return code 0.
{8, 1}
So you just have to be a bit lucky. Since this list is "full enough", it works out
ah, nice
I want to start to learn how python works from behind
where could I get some resources on it?
the best resource ^^
[print(i)for i in range(51)if bin(i)&1]
>>> [print(i)for i in range(51)if bin(i)&1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for &: 'str' and 'int'
[print(i)for i in range(51)if len(bin(i))&1]
``` still shorter
this is not the same
why
.bit_count != .bit_length
the solution likely comes from this
https://codegolf.stackexchange.com/a/144323
the parity bit just needs to be inverted
whats bit_count
!d int.bit_count
int.bit_count()```
Return the number of ones in the binary representation of the absolute value of the integer. This is also known as the population count. Example:
```py
>>> n = 19
>>> bin(n)
'0b10011'
>>> n.bit_count()
3
>>> (-n).bit_count()
3
``` Equivalent to...
huh
have you found the 40 yet
nope
I have an exam tomorrow
after that I have a feeling I'll need to get a pen and paper to solve it
I doubt I can tbh
this feels like a ._. type of problem
a hash function for what type
def h(x):
if isinstance(x,str):return int.from_bytes(x.encode("u8"),"big"))
elif isinstance(x,bytes):return int.from_bytes(x,"big")
else:return x
t=type("",(,),{"__init__":self.a=[0]*200,"__getitem__":lambda x:self.a[h(x)%200],"__setitem__":lambda x,y:self.a.__setitem__(h(x)%200,y)})``` fucked solution
!e
def h(x):
if isinstance(x,str):return int.from_bytes(x.encode("u8"),"big")
elif isinstance(x,bytes):return int.from_bytes(x,"big")
else:return x
t=type("",(,),{"__init__":self.a=[0]*200,"__getitem__":lambda x:self.a[h(x)%200],"__setitem__":lambda x,y:self.a.__setitem__(h(x)%200,y)})
a = t()
a[3] = 4
print(a[3])```
@unique heath :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 5
002 | t=type("",(,),{"__init__":self.a=[0]*200,"__getitem__":lambda x:self.a[h(x)%200],"__setitem__":lambda x,y:self.a.__setitem__(h(x)%200,y)})
003 | ^
004 | SyntaxError: invalid syntax
mk we'll go from there i guess
didnt specify it had to be legit
!e ```py
def h(x):
if isinstance(x,str):return int.from_bytes(x.encode("u8"),"big")
elif isinstance(x,bytes):return int.from_bytes(x,"big")
else:return x
t=type("",(),{"init":lambda x:setattr(x,'a',[0]*200),"getitem":lambda ,x:.a[h(x)%200],"setitem":lambda ,x,y:.a.setitem(h(x)%200,y)})
a = t()
a[3] = 4
print(a[3])
@quartz wave :white_check_mark: Your 3.12 eval job has completed with return code 0.
4
you saw nothing 👀
well other than that you're completely finee
(that is not fine)
def h(x):
if isinstance(x,str):return int.from_bytes(x.encode("u8"),"big")
elif isinstance(x,bytes):return int.from_bytes(x,"big")
else:return x
o=200
t=type("",(),{"__init__":lambda x:setattr(x,'a',[0]*o),"__getitem__":lambda _,x:_.a[h(x)%o],"__setitem__":lambda _,x,y:_.a.__setitem__(h(x)%o,y)})
a = t()
a[3] = 4
print(a[3])```nits
what do you think about using PingFS for swap space?
somebody should implement that
for the swap of something unimportant, yeah
we can use that for storing caches
each ping packet stores integer number of cache entries, and if it gets lost - not a big deal, we can treat it as cache miss, recalculate result and cache it
Isn't the point of a cache to store data for fast + easy reading? From my understanding of storing data in pings, you can only read the data when you get the echo back, which means you'll always get a cache miss unless the result is fetched at the exact same time the echo returns, which could be on the order of hundreds of ms. And if you temporarily store the data locally, what's even the point of storing it in echos in the first place?
for fun
print("Hello")
you tried
dunder spam!! https://paste.pythondiscord.com/S3SQ
any idea how to golf this further
r=range(2,37);*map(print,sorted({l for x in r for y in r if(l:=x**y+y**x)<1e11})),```
prints all leyland numbers (numbers of the form x^y + y^x where 1 < y ≤ x) from 1-100,000,000,000
mines 82 bytes shortest is 73
i can do an 81b from that by using a for loop
(r:=range(2,37),*sorted({k for e in r for v in r if(k:=e**v+v**e)<1e11}))[1:] if you dont need to print them and instead want them as a tuple
also one expression
oh shit is it using that thing where you compress two for loops into one and then mod and floor div them?
oh wait i dont think that works if the range has a start
lmao im such a fucking idiot that was so easy
how did you do this btw?
i got a 74
r=range(2,37);*map(print,sorted({x**y+y**x for x in r for y in r})[:107]),```
ive heard the 73 described as black magic
does anyone know the 58b for fizz buzz from 1-100
ive got a 59
for i in range(100):print(i%3//2*'Fizz'+i%5//4*'Buzz'or-~i)```
why -~i?
because or-~i is shorter than or i+1 or or 1+i
I mean why not just i?
oh
nvm got it
its 1-100 not 0-99
i%3//2 this checks if i === -1 mod 3, not i === 0 mod 3
this might help shorten but idk ```py
for i in range(100):print(i%3//2*'Fizz'+i%5//4*'Buzz'or-~i)
is equivalent to
for i in range(1,101):print((i%4-2)'Fizz'+(i%6-4)'Buzz'or i)
i feel like there should be a better way of doing those minus-even stuff
nvm
doesn't work
Can someone explain in simple words what that rec dict is trying to do? what is the work of the first line in the rec dict?
@flint zodiacs
well you can get rid of the not by switching round your two assignments
also remove white space and rename functions to be one char
you can also put the if else inline
while len(c.keys())<10810803:
x=shuffle_sequence(x))if x in reduce(or_,[*c.values()])else c[x]=create_set(x)```
that should be it i think
also rename shuffle_sequence and create_set to something shorter
!e
a=1 if True else a = 2
@turbid dragon :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | a=1 if True else a = 2
003 | ^^^
004 | SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
yes
I would think it would be
(x:=shuffle_sequence(x)if x in reduce(or_,[*c.values()])else c[x].__setitem__(create_set(x)))
walrus not work on the else?
@turbid dragon :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 2
002 | (x["a"]:=1)
003 | ^^^^^^
004 | SyntaxError: cannot use assignment expressions with subscript
oh yeah i remember that issue
kept running into that trying to solve ascending primes
wtf is reduce(or_, [...])
isnt it the same as any(...)?
Evaluated as a bool yes, but it's value is the first truthy object
Ah no, or_ is |
Source code: Lib/operator.py
The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. Many function names are those used for special methods, without the double underscores. For backward compatibility, many of these have a variant with the double underscores kept. The variants without the double underscores are preferred for clarity.
The functions fall into categories that perform object comparisons, logical operations, mathematical operations and sequence operations.
The object comparison functions are useful for all objects, and are named after the rich comparison operators they support:
does operator have function for "logical" and/or?
No, I just checked
!d operator.not_
operator.not_(obj)``````py
operator.__not__(obj)```
Return the outcome of [`not`](https://docs.python.org/3/reference/expressions.html#not) *obj*. (Note that there is no `__not__()` method for object instances; only the interpreter core defines this operation. The result is affected by the [`__bool__()`](https://docs.python.org/3/reference/datamodel.html#object.__bool__) and [`__len__()`](https://docs.python.org/3/reference/datamodel.html#object.__len__) methods.)
weird description
why is there operator.__not__ at all
why not just operator.not_
I'd do set.union(*my_sets) then
set().union(*my_sets) then
That’s good to know, there’s been a few times I’ve run into wanting to get the first truthy item from a sequence but not known what to do.
I was mistaken though, since operator.or_ does not correspond to or. Just do next(element for element in iterable if element) or next(filter(bool, iterable))
or filter(None if you fancy
!e
is_alife = False
if is_alife != True:
print("Damn you ded")
else:
print("You aint ded yet")
positive 18 and neutral negative 0
n=int(input())
s=0
l=[]
for i in range(0,n):
l.append(int(input()))
for i in l:
if i%2==0:
s+=i
print(s)
while len(c)<max_num:
if{x}&reduce(or_,c.values()):x=shuffle_sequence(x)
else:c[x]=create_set(x)
if{x}&reduce(or_,c.values())
if any(x in c[k]for k in c)
```-1
if any(x in c[k]for k in c)
if any({x}&c[k]for k in c)
``` -1
um so what we doing
codegolfing
i see
codeballing when
theres ccode bowling, where you need to use the longest amount of chars
96b in length ```py
while len(c)<max_num:
if any({x}&c[k]for k in c):x=shuffle_sequence(x)
else:c[x]=create_set(x)
how does that work, if we can create infinitely long variable names?
can we?
wasn't there also a thing with most unique chars (and repeated ones take away points)?
me adding every unicode ccharacter ever
mind explaining how that works?
the if part
what if part
oh yeah im kinda blind lmao
if{x}&reduce(or_,c.values())
this
_ what is it doing there?
ah i see
and reduce(f, a) = f(f(f(a[0], a[1]), a[2]), a[3])...
since the values are sets, it's basically doing set.union(*c.values())
Pythin
because all compound operators must start at the beginning of the line
this is possible in other langs but syntactically it wont work in python
https://gist.github.com/RocketRace/f501ddda25f65a817f7878f09ce84f0f
I made this completely useless 300-line-long regex that matches extended grapheme clusters from a byte stream
example usage:
>>> pattern = ... # gist
>>> import re
>>> string = b'\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf, \xf0\x9f\x8c\x8e! a\xcc\x80\xcc\x80\xcc\x81\xcc\x84\xcc\x8a\xcc\x89\xcc\x8db\xcc\x9b\xcc\x92\xcc\x8d\xcc\xadc\xcc\x98\xcc\x90d\xcc\x9b'
# こんにちは, 🌎! à̀́bcd̄
>>> len(string)
55 # number of bytes
>>> len(string.decode("utf-8")
28 # number of codepoints
>>> len(re.findall(pattern, string))
14 # number of extended grapheme clusters
could you inline it with .__setitem__?
while len(c)<max_num:(any({x}&c[k]for k in c)or c.__setitem__(x,cs(x))and(x:=ss(x))
Finally, someone else who appreciates a stupidly long, overly complex regex (AoC 2023 day 5 spoilers) generation code resulting regex
I love the non-capturing group soup to isolate ors
my initial generated regex was, um. 82,000 lines long
until i started using ranges
yours is also magnificent
amazing. Mine could be shorter, but I decided to have both lookaheads and behinds be fixed-width (as opposed to lookbehinds fixed, while lookaheads variable, which feels ick)
this is not esoteric but it looks
hooray for box drawing characters
j=j[e==']':]+' '[e!='[':]```
anyone able to golf this further?
j starts off as an empty string
What is it supposed to do? Seems like it just turns j into a single space if e is "[", and doesn't do anything otherwise.
it manages indentation for a bf interpreter, it adds another space if e is [, removes one if it's ] and remains the same otherwise
e!='['?
oh
I found that on stack overflow it's really cool I don't think I've seen anything like it before
main=lambda v:print(f"36 + {v} = {36+v}{'...nice.'*(v==33)}")```
can this thing be golfed even further?
expected results: ```
>>> main(33)
36 + 33 = 69...nice.
>>> main(31)
36 + 31 = 67```
main=lambda v:
def main(v):
-1
print(f"36 + {v} = {36+v}"+'...nice.'*(v==33))```
-6 ```py
def main(v):print(f"{36 + v = }"+'...nice.'*(v==33))
i dont this outputs the same thing: ```py
def main(v):print(f"{36 + v = }"+'...nice.'*(v==33))
...
main(33)
36 + v = 69...nice.main=lambda v:print(f"36 + {v} = {36+v}{'...nice.'*(v==33)}")
main(33)
36 + 33 = 69...nice.
note the difference: ```py
36 + v = 69...nice.
36 + 33 = 69...nice.
i also had this idea, but i rejected it because of this
and sadly f'{36 + {v} = }' is not a thing
more concise way to write this?
if k = 5:i+=1
if k = -1:i-=1```
the 5 can be changed to any number from 0-5
if k isnt one of the two selected values though i cant change
x+=(k==5)-(k==-1)
thank you 🙏
aw
i+=k//5
assuming it only goes in range(-1, 6)
yep it does thanks
thank you @restive void @long fulcrum
will there only be one module in python file or is there a chance for multiple modules?
is that supposed to be s/=/==/
wtf
why does the smiley face prints variables
i swear i dont have any emoji-related things in repl
no idea
i don't even know how this could happen by accident
globals() and vars() return different dicts, dir() returns list with correct keys
this is just standard repl?
that is interesting
i figured it out!
do tell
1
i have an excepthook that handles SyntaxErrors with ? symbol in the source code
this allows me to do foo? in the repl: it will raise SyntaxError, my excepthook will capture that and will run help(foo). This is a lot more convenient than doing help(foo) all the time
when i was writing this, i thought: what if i enter only ? symbol without anything else? i dont want to run help(), i should do something else instead
and i decided to print filtered value of __main__.__dict__
code looks like this: ```py
def syntax_excepthook(typ: type[SyntaxError], val: SyntaxError, tb: types.TracebackType | None):
if val.text is None or '?' not in val.text:
return base_hook(typ, val, tb)
if val.filename != '<stdin>':
return base_hook(typ, val, tb)
text = val.text.replace('?', '').strip()
import __main__
if not text:
# display locals
x = __main__.__dict__
x = {k: v for k, v in x.items() if not k.startswith('__')}
sys.displayhook(x)
return
try:
obj = eval(text, __main__.__dict__)
except Exception as exc:
exc = exc.with_traceback(None)
return base_hook(exc.__class__, exc, None)
help(obj)
and then i completely forgot about this feature because i can get locals in a standard way: `locals()` / `globals()`
# 2
when i paste emojis to my terminal, they for some reason are converted to `??` under the hood
you can see this in reprs of such strings on my screenshots - they are indeed ascii `??`, not something unicode-ish
so, i am entering `??` into repl, it raises `SyntaxError`, excepthook strips all `?` and finds empty string - it means it should print `__main__.__dict__`!
thats very silly
wdym?
it was a sed reference
i was asking if if k = 5:i+=1 was supposed to be if k == 5:i+=1 (because the former isn't valid python syntax)
oh shit yeah didnt even notice 😭
anyone have any idea how to do this with a start step
for i in range(0, s1*n, s1):
for j in range(0, s2*m, s2):
do(i, j)
for k in range(n*m):
do(k//m*s1,k%m*s2)
it should be //, not /
for i in range(a, a+s1*n, s1):
for j in range(b, b+s2*m, s2):
do(i, j)
for k in range(n*m):
do(a+k//m*s1,b+k%m*s2)
``` didnt test, but i think this should work
yeah most golfed python on the site is python2
let me try that out
stuff you can do heavily depends on particular properties of (start,stop,step) values
i dont think you can do much in general, but in special cases you can do cool tricks
for i in range(a1, b1, c1):
for j in range(a2, b2, c2):
do(i, j)
print('#')
n1 = (b1-a1)//c1
n2 = (b2-a2)//c2
for k in range(n1*n2):
do(a1 + k // n2 * c1, a2 + k % n2 * c2)
``` this is the general case
if you shorten names and remove whitespace, it looks like this: ```py
# 56 chars
for x in range(x,x,x):
for x in range(x,x,x):
do(x,x)
# 64 chars
x=(x-x)//x
x=(x-x)//x
for x in range(x*x):
do(x+x//x*x,x+x%x*x)
not sure if im misunderstanding but cant get them to output the same thing
for i in range(2,4):
for j in range(2,4):
print(i,j)
print()
for k in range(4*4):
print(2+k//4,2+k%4)```
you are misunderstanding
this works only for ranges of form range(0, step*count, step)
if steps just 1 though can it not just be removed
yes, i mentioned it here 
do=print
a,b,c,d=2,4,2,4
# 52
for i in range(a,b):
for j in range(c,d):
do(i,j)
print('#')
# 48
m=d-c
for k in range((b-a)*m):
do(a+k//m,c+k%m)
i have 78
r=range(2,37);*map(print,sorted({x**y+y**x for x in r for y in r})[:107]), # 74, with help from @firegene
r=range(2,37);print(*sorted({x**y+y**x for x in r for y in r})[:107],sep='\n')
r=range(2,37);print(*sorted(x**y+y**x for x in r for y in r if x>=y)[:107],sep='\n')
print(*sorted({(a:=2+k//35)**(b:=2+k%35)+b**a for k in range(1225)})[:107],sep='\n')
print(*sorted({(a:=k//35)**(b:=2+k%35)+b**a for k in range(70,1295)})[:107],sep='\n')
print(*sorted({(k//35)**(b:=2+k%35)+b**(k//35)for k in range(70,1295)})[:107],sep='\n')
print(*sorted({(2+k//35)**(2+k%35)+(2+k%35)**(2+k//35)for k in range(1225)})[:107],sep='\n')
(x)**(y)
pow(x,y)
(k//n)**(k%n)
pow(k//n,k%n)
pow(*divmod(k,n))
nice
are you aware of this page? https://codegolf.stackexchange.com/questions/82981/leyland-numbers
i stole the main idea from here
yeah any time I go to golf something I always check that site first
is there any way to not have to assign j
"string"[j:='><+-.['.find(i)];c+=j//5```
you can save the char and do c=='['
t:='string'[...];c+=t=='['
"string"[j:='><+-.['.find(i)];c+=j//5
t:="string"['><+-.['.find(i)];c+=t=='['
``` not really helpful
nope
looks like I'll be stuck on 183 for brainfuck for a while then
atp I feel the optimal solution is completely different from mine
it's 167
I feel like I need a rewrite
!e
print(chr((32 << 1) + 40)+chr((((((1 << 4) + 4) << 2) + 3) & 127) + ((1 << 3) + 10))+chr((((((1 << 4) + 5) << 2) + 5) & 127) + ((1 << 3) + 11))+chr((((((1 << 4) + 2) << 2) + 2) & 120) + ((2 << 3) + 20))+chr((47 << 1) + (64 >> 5) + 15))```
@sick reef :white_check_mark: Your 3.12 eval job has completed with return code 0.
hello
Anyone want to give me the run down on how bitshifts are made?
I understand the concept just not how people make them.
<<n === *2**n
impressive ngl
!e
num1 = 10
print(num1 ** 3)
@sick hound :white_check_mark: Your 3.12 eval job has completed with return code 0.
1000
uhhhhhhhhhh
A barrel shifter is a digital circuit that can shift a data word by a specified number of bits without the use of any sequential logic, only pure combinational logic, i.e. it inherently provides a binary operation. It can however in theory also be used to implement unary operations, such as logical shift left, in cases where limited by a fixed a...
how exactly are we supposed to program in it
15 opcodes (0, 15) - 1 parameter byte and 2 bytes for entropy for the random number generator
pass your program as a list to the interpret function
interpret([0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2])
and... what exactly d othose opcodes do
def do_next_instruction(instruction, stack, ptr):
# all instructions must be 4 bytes, even instructions which don't require parameters
# instruction_byte [0 - 15], parameter [0 - 256], halftime_entropy_byte_1 [0 - 256], halftime_entropy_byte_2 [0 - 256]
if len(instruction) != 4:
return
if instruction[0] > 15 or instruction[1] > 255 or instruction[2] > 255 or instruction[3] > 255:
return
p = -1
match instruction[0]:
case 0:
stack[ptr] -= 6
case 1:
if ptr > stack[ptr]:
stack[ptr] = (ptr % 217)
ptr += 7
else:
ptr -= 7
if ptr < 0:
ptr = 6
case 2:
stack[ptr] += int(instruction[1] * 0.7)
case 3:
stack[ptr] -= int(instruction[1] * 0.7)
case 4:
c = stack[0]
d = stack[1]
e = stack[2]
if c < d * e and ptr < 128:
stack[ptr] = 0
elif d < c * e and ptr > 128:
stack[ptr] = 1
else:
stack[ptr] ^= e
case 5:
stack[ptr] += stack[0]
case 6:
stack[ptr] += instruction[0]
case 7:
stack[ptr] += instruction[1] * instruction[0] - 6
case 8:
stack[int(ptr * 0.56) % 200] ^= (instruction[0] + instruction[1] + 2) % 27
case 9:
ptr = 8
for i in range(0, 32):
stack[i] = (stack[i + 1] ^ stack[i * 2])
case 10:
stack[ptr] = stack[instruction[1]]
case 11:
p = stack[ptr]
case 12:
ptr -= 1
case 13:
ptr = (ptr ^ instruction[1]) % 240
case 14:
ptr += 1
case 15:
ptr += 1 if ptr % 2 == 0 else -1
if ptr > 255 or ptr < 0:
ptr = 32
elif stack[ptr] > 255 or stack[ptr] < 0:
stack[ptr] = 0
return [stack, ptr, p]
🥴
mostly just random operations, however basic arithmatic is supported too
also after every instruction is performed, a completely random one is also generated and performed so you kinda just gotta keep changing the entropy bytes until you find an instruction which helps you out or kinda does nothing
i dont think this is turing complete
it is not no
- it literally wouldnt be possible to hello world
its possible to do hello world
you cant output anything
it would only be able to utput numbers
chr(byte)
if you can get the print_array to become [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33] then you've basically printed hello world
chr isnt an opcode?
you can print the array right at the end if you want to, but the reason i've done it this way as to not print everything is that it would just fill the terminal with random shit when the testing function is performed
print("".join(map(chr, interpret(instructions)[2])))
but anyway, i modified the interpret function to have a should_print parameter which when true will print the bytes at the end of execution
discovered something unintended inside the code which makes printing any string pretty easy to do, i'd be surprised if anybody else finds it out though. managed to get a print("Hello World!")
||[2, 103, 0, 10, 2, 42, 0, 12, 2, 11, 0, 6, 2, 0, 0, 55, 2, 5, 0, 20, 3, 113, 0, 11, 2, 79, 0, 26, 2, 35, 0, 9, 2, 5, 0, 20, 3, 9, 0, 11, 3, 12, 0, 3, 3, 97, 0, 2] prints "Hello World!"||
You can just keep stack[0] as 0, and then choose your instructions such that one of the two (random or not) is 5 mod 16, then the whole randomness doesn't matter
You have incrementing, decrementing (by 6, but who cares), jumps, and two kinds of conditionals.. are you sure it's not Turing complete?
it may be, i didn't think of it that way
and also printing any string can be done just by increasing the entropy bytes until the generated random instruction has it's first byte set to 11 which is the print instruction (which is only 1/16 odds)
!eval ```py
print(bytes([2, 103, 0, 10, 2, 42, 0, 12, 2, 11, 0, 6, 2, 0, 0, 55, 2, 5, 0, 20, 3, 113, 0, 11, 2, 79, 0, 26, 2, 35, 0, 9, 2, 5, 0, 20, 3, 9, 0, 11, 3, 12, 0, 3, 3, 97, 0, 2]))
@lunar juniper :white_check_mark: Your 3.12 eval job has completed with return code 0.
b'\x02g\x00\n\x02*\x00\x0c\x02\x0b\x00\x06\x02\x00\x007\x02\x05\x00\x14\x03q\x00\x0b\x02O\x00\x1a\x02#\x00\t\x02\x05\x00\x14\x03\t\x00\x0b\x03\x0c\x00\x03\x03a\x00\x02'
!eval ```py
print(bytes([2, 103, 0, 10, 2, 42, 0, 12, 2, 11, 0, 6, 2, 0, 0, 55, 2, 5, 0, 20, 3, 113, 0, 11, 2, 79, 0, 26, 2, 35, 0, 9, 2, 5, 0, 20, 3, 9, 0, 11, 3, 12, 0, 3, 3, 97, 0, 2]).decode())
@lunar juniper :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | g�
002 | *�
003 |
004 | ���7�q�
005 | O�#� � �
006 |
007 | �a�
what did you expect?
print "hello world"
like this said
it's using this
Hello, I am facing module 'bcrypt' has no attribute 'about' when usin CryptContext from passlib
Does anyone have a clue ?
It looks like passlib is currently broken until the maintainers update the code/pin bcrypt to a lower version. See the relevant issue on bcrypt and the resulting issue for passlib
okay, so the workaround is to specify a version in the pipfile .
Do you know whats wrong? I specified the Version :
[packages]
fastapi = "*"
uvicorn = "*"
httpx = "*"
pydantic = "*"
sqlalchemy = "*"
cryptography = "*"
bcrypt = "3.2.2"
pytz = "*"
python-jose = "*"
email_validator = "*"
mysqlclient = "*"
But i still get the error message
this is the wrong channel for that
where is the right channel ?
I'm trying to create an exif tool that will do something that i want it to do.
I want to figure out why every image i check have these tags ( i checked 6-7 images).
I want to create a tool to generate fake-metadata for images and i want to figure out a few configurations of camera models that generate EXIF meta.
so basically i want some data that i want to stick to images i give, (fake data to real images)
can anyone help me 🙂
this is a weird topic
there should be a 'cameras' channel
you probably need to check the image formatting system (how do they store metadata) and change it
And I would recommend you to send this in https://discord.com/channels/267624335836053506/971142229462777926
!e ```py
ᅠ = 0
ᅠᅠ = ᅠ + ᅠ
print(ᅠ + ᅠᅠ)
class ᅠᅠᅠ():
ᅠᅠ: int
def ᅠ(ᅠ, ᅠᅠ):
return ᅠ.ᅠᅠ + ᅠᅠ
ᅠᅠᅠᅠ = ᅠᅠᅠ()
ᅠᅠᅠᅠ.ᅠᅠ = 42
print(ᅠᅠᅠᅠ.ᅠ(ᅠᅠ))
@fleet bridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0
002 | 42
!e
def xor(flip, ret, cont):
def cont1(x):
def cont2(y):
return ret((x and (not y)) or ((not x) and y), cont)
return flip(cont2)
return flip(cont1)
def main():
xor_values = xor(
lambda cont: cont(True) + cont(False),
lambda x, cont: cont([x]),
lambda x: x
)
print(xor_values)
if __name__ == '__main__':
main()
@pine wolf :white_check_mark: Your 3.12 eval job has completed with return code 0.
[False, True, True, False]
!e ```py
for x, xᅠforᅠx in enumerate(range(10)):
print(x, xᅠforᅠx)
print([xᅠforᅠx in range(10)])
@fleet bridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0 0
002 | 1 1
003 | 2 2
004 | 3 3
005 | 4 4
006 | 5 5
007 | 6 6
008 | 7 7
009 | 8 8
010 | 9 9
011 | [True]
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/E7UMVOS7YCK5A7VCWVWEA27Q5I
lmao
!charinfo
characters
!charinfo <characters>
Shows you information on up to 50 unicode characters.
\u006e : LATIN SMALL LETTER N - n
\u0020 : SPACE -
\u0065 : LATIN SMALL LETTER E - e
\u006e\u0020\u0065
!charinfo r x, xᅠforᅠx
\u0072 : LATIN SMALL LETTER R - r
\u0020 : SPACE -
\u0078 : LATIN SMALL LETTER X - x
\u002c : COMMA - ,
\u0020 : SPACE -
\u0078 : LATIN SMALL LETTER X - x
\uffa0 : HALFWIDTH HANGUL FILLER - ᅠ
\u0066 : LATIN SMALL LETTER F - f
\u006f : LATIN SMALL LETTER O - o
\u0072 : LATIN SMALL LETTER R - r
\u0072\u0020\u0078\u002c\u0020\u0078\uffa0\u0066\u006f\u0072\uffa0\u0078
An imposter is among us
!charinfo ᅠᅠ
\u0060 : GRAVE ACCENT - `
\u1160 : HANGUL JUNGSEONG FILLER - ᅠ
\uffa0 : HALFWIDTH HANGUL FILLER - ᅠ
\u0060 : GRAVE ACCENT - `
\u0060\u1160\uffa0\u0060
ᅠ<
ᅠ<
for some reason when pyright does autocomplete, it suggests the wide one -_-
!charinfo Ɛඞ
\u0190 : LATIN CAPITAL LETTER OPEN E - Ɛ
\u0d9e : SINHALA LETTER KANTAJA NAASIKYAYA - ඞ
\u0190\u0d9e
what is the point of this
effect handlers using continuation passing
I'll have to remember that tuples are an option for when you don't care about the return value. Since I usually do stuff inside lambdas that need to return, I default to and/or ```py
print(import("requests").get("https://httpbin.org/get").text)
For this at least, if you only need `requests`/`resp` once you can get rid of them and just chain the calls.
Could anyone explain why a dunder import exists like this?/why is it a dunder
There’s multiple dunder methods like these that are unrelated to the classic OOP related dunder methods
Not sure why they exist and what they do
Just like how in classes dunder methods do magic, the same applies at the module level. The data model page has a full list. https://docs.python.org/3/reference/datamodel.html#modules . __import__ is how you can change the behavior of the import statement. One example I remember is this #1159960081186697296 message that uses it to get the actual python implementation of functools instead of the c implementation. There is also file-level dunders like __init__.py.
tldr python uses dunders for basically anything that invokes internal magic, not just class related things.
__import__ is the only standalone dunder function afaik, are there more of them?
I guess there's __all__ and __doc__ at the module level, but they aren't functions
ah, i saw it as such mb
I just assume they meant all dunder attributes, since not everything is a method even at class level, like __code__
__build_class__
!e print(__build_class__)
@fleet bridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
<built-in function __build_class__>
it implements class statement
I wonder if there's an equivalent for type as a soft keyword
there is also a lot of import-related stuff: __name__, __path__, __loader__, __spec__, __file__
wdym?
Or I guess that might also resolve to class? The 3.12 type x = int
also __builtins__, __package__ and __annotations__
I found https://docs.python.org/3/reference/import.html#import-related-module-attributes that also has __cached__. Is there really not a comprehensive list anywhere :/
all of it are implementation details
well, not all
but i wouldnt be surprised if some python implementations dont have most of this stuff
oh yeah __debug__ exists too
it is a keyword
kinda
!e ```py
debug # ok
debug = x # err
import builtins
builtins.debug # ok
builtins.debug = x # err
builtins.dict['debug'] # ok
builtins.dict['debug'] = x # ok
@fleet bridge :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 2
002 | __debug__ = x # err
003 | ^^^^^^^^^
004 | SyntaxError: cannot assign to __debug__
for some reason it exists in builtins, but is never used, because compiler replaces it with True/False
That reminds me of this thing that exists #python-discussion message
$ cat o.py
def f():
'f'
x = bool(f.__doc__)
assert (x := x + 1)
print('-' + 'O'*(2-x))
f()
$ python o.py
-
$ python -O o.py
-O
$ python -OO o.py
-OO
bruh
im interested, how often do you use -O/-OO? i never use it because it doesnt make a difference for me
Never, I run all my things through pycharm anyways so I'd have to make a run configuration to do it.
def f():
'-'
b = 'O'
assert not (b := '')
print(f.__doc__ or '-O' + b)
f()
``` golfed
i just have key binding that runs current file, i use it 99% of times. In rare cases i have to go to terminal
(in the past i used to use shebang-style run configuration directly in the file, that was parsed every time i press ctrl+b, but i removed it because it was ugly af)
I like my current workflow since it helps keep the languages seperated in my mind. python is press the button, c# is ctrl+b/ctrl+r ingame, rust is terminal.
ig you can use module-level __doc__ and save 3 chars: f. and space for indentation
-5 chars ```py
'-'
b='O'
assert not(b:='')
def f():
print(doc or'-O'+b)
f()
discord being discord
hooray for fun edge cases, like you have 1or"" but not 0or""
assert not(...) -> assert'x'+(...)?
Oh wait that's the same length
How about assert(...)or 1
Nope
syntax highlighting with regex caught in 4k
How about```py
'-'
b=0
assert(b:=1)
def f():
print(doc or'-OO'[:-b])
f()
!e ```py
assert(b:=0),
@gleaming linden :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | assert(b:=0),
003 | ^
004 | SyntaxError: invalid syntax
!e ```py
assert[b:=0]
@gleaming linden :warning: Your 3.12 eval job has completed with return code 0.
[No output]
why is the function needed
prints all - for me
58 ```py
'-O'
t=doc
assert(t:='-')
def f():print(t or'-OO')
f()
what does that even do
w/o the function it's 46 ```py
'-O'
t=doc
assert(t:='-')
print(t or'-OO')
>python test_it.py && python -O test_it.py && python -OO test_it.py
-
-O
-OO
bonus: print X when -x is given as a command line option, no matter the optimization level
'-'
b='O'
assert not(b:='')
def f():print(__doc__ or'-O'+b)
f()
```-2
from that code
Is anyone here willing to deobfuscate code ?
Hit me up if so.I believe this one is kinda hard.
is it malicious or?
What do you mean by malicious ?
I can't know since it's obfuscated.
where did you get it?
I know what it does.
Github
It's a source that i need to work on a project i have. It just creates proxies on your own pc. Can you help me ?
I'm not running an obfuscated script on my pc, but idm attempting to deobfuscate it
Ok, should i send you the github ?
just send it here
ok
Contribute to xoloking/limited_sniper development by creating an account on GitHub.
this is i t
@low lynx let me know if any progress if you dont mind.
Not a valid Python file?
Thats the issue.
However it runs as python if you inspect start.bat
Is this a roblox limited sniper script? We don't help with those here unfortunately
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
It doesn't, at least not on my system.
I dont want help making it. I just want to know the source of the script which is creating proxies.
The limited sniper is already done. (not by me)
$ python main.py
SyntaxError: Non-UTF-8 code starting with '\xa7' in file /path/to/main.py on line 1, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
mhm, and we aren't going to help deobfuscate this script
that's weird I dont know
~It's ok
I understand.
@limpid osprey can we have the discussion here?
Okay, then where shall we have it?
!e
x = 'X'
if x == 'A' or 'B' or 'C': print("True")
else: print("False")
@finite blaze :white_check_mark: Your 3.12 eval job has completed with return code 0.
True
!or-gotcha
When checking if something is equal to one thing or another, you might think that this is possible:
# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
!e ```py
import dis
dis.dis("x == 'A' or 'B' or 'C'")
@fleet bridge :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0 0 RESUME 0
002 |
003 | 1 2 LOAD_NAME 0 (x)
004 | 4 LOAD_CONST 0 ('A')
005 | 6 COMPARE_OP 40 (==)
006 | 10 COPY 1
007 | 12 POP_JUMP_IF_TRUE 3 (to 20)
008 | 14 POP_TOP
009 | 16 LOAD_CONST 1 ('B')
010 | 18 RETURN_VALUE
011 | >> 20 RETURN_VALUE
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/NIEGL5SEUXLX4PL2SLMG72TD7Y
So whats the shortest way to create an iterable of size n where n is in the form of a string
"x"*int(n)
Is the shortest ive found so far, but im wondering if theres a fancy fstring or % logic available for this
my solution is a whole 10 characters
f"{0:<{x}}"
is eleven characters
not so useful then is it 
Ah, you can drop the <, but that's the same then
hmm, maybe theres a % alternative for this?
to avoid the f and {}
I have no clue how python2 formatting works though
i was also thinking of tuple/list/set multiplication
f"%{x}d"%0 is again 10 chars. You need the f-string because of the nesting (we want x in the format specifier itself)
I think this is probably the limit.
grr
wait
Nvm, I was thinking "we know what n is", but no, its to be dynamic
Hmm, if n is known to be a single character then actually
n*int(n)
But I'm actually using n as a substitute for input() so that wouldn't really work
[ (a_p, s_p, d_p)
for d_p in d_hs
for i2, d_hs in enumerate(A)
for j2, s_p in enumerate(a_hs)
for j, a_p in enumerate(a_hs)
for i, a_hs in enumerate(A)
if i != i2 and j != j2
]```
We'll do a little batch loading [with true formating]
this is just like that one PEP 8 superseder
it's almost like we're in the channel for python monstrosities
i'm just curious if that's intentional or not
eh i don't know what to expect given the unique indentation style
also itertools.combinations moment
what the heck
or product?
@dense mural can u help me
How? And Why Not #❓|how-to-get-help
Using DFS for maze gen goes crazy
ah yes, minimum line length. What could possibly go wrong?
where is that?
Created for 2022 april fools
ok
ProgrammerNotKindEnough exception vibes
This looks like something I made when I was trying to make a script not have dependencies when I really should've used numpy
!e
exec( bytes( x & # ex-ec bytes x and
255 # two hun-dred and fif-ty five
for x in map( ord # for x in map ord
,""))) # ~
@radiant anchor :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 1
002 | 2
003 | fizz
004 | 4
005 | buzz
006 | fizz
007 | 7
008 | 8
009 | fizz
010 | buzz
011 | 11
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/44AUKTVDZCKM7ZZU3IG7LYF3BY
wh- ```pycon
t=b.decode()
from unicodedata import name
name(t[0])
'TAG LEFT SQUARE BRACKET'
name(t[1])
'TAG LATIN SMALL LETTER P'
name(t[2])
'TAG LATIN SMALL LETTER R'
name(t[2])
'TAG LATIN SMALL LETTER R'
name(t[4])
'TAG LATIN SMALL LETTER N'
name(t[5])
'TAG LATIN SMALL LETTER T'
name(t[6])
'TAG LEFT PARENTHESIS'
name(t[7])
'TAG QUOTATION MARK'
name(t[8])
'TAG LATIN SMALL LETTER F'
name(t[9])
'TAG LATIN SMALL LETTER I'
😎
whjg ```py
[print("fizz"(1-i%3)+"buzz"(1-i%5)or i)for i in range(1,101)]
yeah that was my attempt at idiomatic-yet-concise fizzbuzz
(with emphasis on the concise, lol)
oh wait i didn't have to construct that manually- ```pycon
print("".join(unicodedata.lookup(x[4:]) for x in map(name, t)))
[print("fizz"(1-i%3)+"buzz"(1-i%5)or i)for i in range(1,101)]
I mean, you could just run the script sans exec
or replace exec with print, rather
!e exec(bytes(ord(x)&255 for x in""))
@radiant anchor :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 1
002 | 2
003 | fizz
004 | 4
005 | buzz
006 | fizz
007 | 7
008 | 8
009 | fizz
010 | buzz
011 | 11
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/DDC2PPWAR2TJL7B5VZIBFS5V5A
the actual fuc
oh i get it
exec(bytes(ord(x)&255 for x in 'print("fizzbuzz")'))
another variation (does the same thing, but more misleading)
Wrote a brainfuck interpreter in python
write a brainfuck interpreter in brainfuck
I would have no idea where to begin
a, *b = 1, 2, 3
print(f"a: {a}, b: {b}")
# a: 1, b: [2, 3]
def foo(a, *b):
print(f"a: {a}, b: {b}")
foo(1, 2, 3)
# a: 1, b: (2, 3)
Why does the former become a list and the latter become a tuple?
the basic idea is that lots of algorithm like to use unpacking, then modify the list, while you shouldn't be modifying arguments
a = 1, 2
b = *a, # last comma is needed!
print(b)
Hey All,
I want to know the names of some of the RPA tools which are not cloud native?
wrong channel owo
Repost:
Can we evaluate 5! (five factorial) with list comprehension?
input = range(1, 6)
output = [....]
print(output)
Any difficulty, complexity, verbosity, etc are always welcome because it is only for learning purposes.
!e
my personal favourite is
print([
a[0]
for a in [[1]]
for i in range(1, 6)
for a[0] in [a[0] * i]
][-1])
@proper vault :white_check_mark: Your 3.12 eval job has completed with return code 0.
120
It is a funny button. If I click it, the bot says "This is not your button to click!".
So why did the bot provide me with this button? 🙂
The button no longer exists now.
likely the option to show a button to a single person didn't exist or doesn't exist
or we just didn't know about it
Theres a couple too many for loops in here for my liking; does anyone have any ideas on how to reduce the tokens?
(PA:=str.__call__().join([chr(x)for(x)in[((None,sum((range.__call__(int.__call__((3-1j).real-1),7))),True)[1]-1)*10**1//2]*2])),(_x_B:=lambda A____,_B:(z:=(complex.__call__(*[9,2])-3j)).real%4),(AP:=PA),(AAAAA:=lambda __,_:(~int(_x_B(__,_)))),(GGENN:=lambda *a:-1),(ZZZ_ :=type("_yy", (), {"__sub__":AAAAA,"__mod__":lambda *a:-1,rf"{PA}add{AP}":_x_B,"__mul__": _x_B,"f":lambda m:[a is Ellipsis or a>=1 for a in m],"__UU9":list(),"__truediv__":lambda *A:1j,"__gt__":lambda *_:0,"imag":None,"__matmul__":lambda xX,Xx:3+3-3,fr"{PA}rox{PA}"[::-1]:lambda Zz,zZ:int(False)>True,"__ge__":GGENN})),(CC_:="ETIANMSURWDKGOHVF L PJBXCYZQ"),(YZ_A:=[[]])
def p(*x:__import__("typing").Any,_:__import__((CC:="fishhook")).hook.cls(type(...))(ZZZ_)={}):
for(eEE_,_ALz )in(ne:=enumerate)(x):
if(_ALz.imag)or _ALz>2:ZZZ_.__UU9=[*ZZZ_.__UU9,ZZZ_.f(list(x[(tt:=len(sum(ZZZ_.__UU9,start=[])))+len(list(filter(bool,ZZZ_.__UU9))) if(ZZZ_.__UU9)else 0:eEE_])),*list(filter(lambda m:isinstance(m,list),[None if not(not _ALz.imag and _ALz>2)else[]]))]
for(LLZZ_)in ZZZ_.__UU9:
if(YZ_A.append([])or(p:=0)or LLZZ_ ==[]):continue
for(M_SA)in([*LLZZ_,*([True]if(z:=YZ_A.pop())else[])] ):p=2*p+(int(M_SA)-1)*-1
YZ_A[-1].append(CC_[(2**(len(LLZZ_ ))-1+p)-1])
return(chr(32).join([str.__call__().join(__)for __ in YZ_A]))
print(p(...,...,...*...,...==...,.../...,...,.../...,...,...-...,...+...,...+...,.../...,...,...-...,...+...,...+...,.../...,...-...,...-...,...-...,...@...,...*...,...^...,...-...,.../...,...!=...,...<=...,...%...,.../...,...,...-...,...,.../...,...,...-...,...+...,...*...,.../...,...-...,...,...*...,.../...))
Or all the overrides here
{"__sub__":AAAAA,"__mod__":lambda *a:-1,rf"{PA}add{AP}":_x_B,"__mul__": _x_B,"f":lambda m:[a is Ellipsis or a>=1 for a in m],"__UU9":list(),"__truediv__":lambda *A:1j,"__gt__":lambda *_:0,"imag":None,"__matmul__":lambda xX,Xx:3+3-3,fr"{PA}rox{PA}"[::-1]:lambda Zz,zZ:int(False)>True,"__ge__":GGENN}
which are a bit obvious
how to reduce the tokens
remove all the nonsense from it
complex.__call__(*[9,2])->complex(9, 2)
chr(32)->" "
str.__call__()->""
and so on
theres a lot of useless stuff going on in it
Here are three levels of "Do you know your python syntax?"
Level 1. Which of the following lines are valid?
(a) = 1
(a) = 1,
[a] = 1
[a] = 1,
Ans: || Line 1,2,4||
Level 2. Which of the following lines are valid?
[a,b] ,= [[1,2]]
() = ()
(,) = (,)
[] = []
[,] = [,]
Ans: ||Line 1,2,4||
Level 3. Which of the following lines are valid
*a = ()
*a ,= ()
(*a) = ()
[*a] = ()
Ans: || 2 and 4||
Bonus level: ||Is this valid: *[a,a] ,= (1,2)?||
yes
another bonus level: ||Tell the value of a and b in of: a,*b,=([*[1,2,3]],*[1,2,3])||
||```
a,b,=([[1,2,3]],*[1,2,3])
a is [1, 2, 3]
b is [1, 2, 3]
Wtf...
ah shit i didnt see the sneaky pistol op
Darn, got many wrong
WHAT THE FUCK, WHY YOU CAN RUN WITH A ",", THIS IS NOT MY PYTHON I'M QUITTING
PYTHON IS DOOMED, IT IS NOT CLEAN ANYMORE
since before 3.0 :)
valid syntactically or valid==not raising errors?
4 surprised me
no language is clean
also unclean code is the point of this channel
the channel description itself states the point of this channel
YOU RUINED MY PYTHON CURESE YOU!!!!
CURSECURSE!!!!
Warcrimes
hmm, now when i think about it again, there is no line that raises errors at runtime
they all either fail syntactically, or work fine
!e Theres a couple too many for loops in here for my liking; does anyone have any ideas on how to reduce the tokens?
(PA:=str.__call__().join([chr(x)for(x)in[((None,sum((range.__call__(int.__call__((3-1j).real-1),7))),True)[1]-1)*10**1//2]*2])),(_x_B:=lambda A____,_B:(z:=(complex.__call__(*[9,2])-3j)).real%4),(AP:=PA),(AAAAA:=lambda __,_:(~int(_x_B(__,_)))),(GGENN:=lambda *a:-1),(ZZZ_ :=type("_yy", (), {"__sub__":AAAAA,"__mod__":lambda *a:-1,rf"{PA}add{AP}":_x_B,"__mul__": _x_B,"f":lambda m:[a is Ellipsis or a>=1 for a in m],"__UU9":list(),"__truediv__":lambda *A:1j,"__gt__":lambda *_:0,"imag":None,"__matmul__":lambda xX,Xx:3+3-3,fr"{PA}rox{PA}"[::-1]:lambda Zz,zZ:int(False)>True,"__ge__":GGENN})),(CC_:="ETIANMSURWDKGOHVF L PJBXCYZQ"),(YZ_A:=[[]])
def p(*x:__import__("typing").Any,_:__import__((CC:="fishhook")).hook.cls(type(...))(ZZZ_)={}):
for(eEE_,_ALz )in(ne:=enumerate)(x):
if(_ALz.imag)or _ALz>2:ZZZ_.__UU9=[*ZZZ_.__UU9,ZZZ_.f(list(x[(tt:=len(sum(ZZZ_.__UU9,start=[])))+len(list(filter(bool,ZZZ_.__UU9))) if(ZZZ_.__UU9)else 0:eEE_])),*list(filter(lambda m:isinstance(m,list),[None if not(not _ALz.imag and _ALz>2)else[]]))]
for(LLZZ_)in ZZZ_.__UU9:
if(YZ_A.append([])or(p:=0)or LLZZ_ ==[]):continue
for(M_SA)in([*LLZZ_,*([True]if(z:=YZ_A.pop())else[])] ):p=2*p+(int(M_SA)-1)*-1
YZ_A[-1].append(CC_[(2**(len(LLZZ_ ))-1+p)-1])
return(chr(32).join([str.__call__().join(__)for __ in YZ_A]))
print(p(...,...,...*...,...==...,.../...,...,.../...,...,...-...,...+...,...+...,.../...,...,...-...,...+...,...+...,.../...,...-...,...-...,...-...,...@...,...*...,...^...,...-...,.../...,...!=...,...<=...,...%...,.../...,...,...-...,...,.../...,...,...-...,...+...,...*...,.../...,...-...,...,...*...,.../...))
@unreal echo :white_check_mark: Your 3.12 eval job has completed with return code 0.
HELLO WORLD
!timeit
(PA:=str.__call__().join([chr(x)for(x)in[((None,sum((range.__call__(int.__call__((3-1j).real-1),7))),True)[1]-1)*10**1//2]*2])),(_x_B:=lambda A____,_B:(z:=(complex.__call__(*[9,2])-3j)).real%4),(AP:=PA),(AAAAA:=lambda __,_:(~int(_x_B(__,_)))),(GGENN:=lambda *a:-1),(ZZZ_ :=type("_yy", (), {"__sub__":AAAAA,"__mod__":lambda *a:-1,rf"{PA}add{AP}":_x_B,"__mul__": _x_B,"f":lambda m:[a is Ellipsis or a>=1 for a in m],"__UU9":list(),"__truediv__":lambda *A:1j,"__gt__":lambda *_:0,"imag":None,"__matmul__":lambda xX,Xx:3+3-3,fr"{PA}rox{PA}"[::-1]:lambda Zz,zZ:int(False)>True,"__ge__":GGENN})),(CC_:="ETIANMSURWDKGOHVF L PJBXCYZQ"),(YZ_A:=[[]])
def p(*x:__import__("typing").Any,_:__import__((CC:="fishhook")).hook.cls(type(...))(ZZZ_)={}):
for(eEE_,_ALz )in(ne:=enumerate)(x):
if(_ALz.imag)or _ALz>2:ZZZ_.__UU9=[*ZZZ_.__UU9,ZZZ_.f(list(x[(tt:=len(sum(ZZZ_.__UU9,start=[])))+len(list(filter(bool,ZZZ_.__UU9))) if(ZZZ_.__UU9)else 0:eEE_])),*list(filter(lambda m:isinstance(m,list),[None if not(not _ALz.imag and _ALz>2)else[]]))]
for(LLZZ_)in ZZZ_.__UU9:
if(YZ_A.append([])or(p:=0)or LLZZ_ ==[]):continue
for(M_SA)in([*LLZZ_,*([True]if(z:=YZ_A.pop())else[])] ):p=2*p+(int(M_SA)-1)*-1
YZ_A[-1].append(CC_[(2**(len(LLZZ_ ))-1+p)-1])
return(chr(32).join([str.__call__().join(__)for __ in YZ_A]))
print(p(...,...,...*...,...==...,.../...,...,.../...,...,...-...,...+...,...+...,.../...,...,...-...,...+...,...+...,.../...,...-...,...-...,...-...,...@...,...*...,...^...,...-...,.../...,...!=...,...<=...,...%...,.../...,...,...-...,...,.../...,...,...-...,...+...,...*...,.../...,...-...,...,...*...,.../...))
@unreal echo :white_check_mark: Your 3.12 timeit job has completed with return code 0.
1 loop, best of 5: 634 usec per loop
!timeit
print('HELLO WORLD')
@unreal echo :white_check_mark: Your 3.12 timeit job has completed with return code 0.
500000 loops, best of 5: 694 nsec per loop
Smh
TIL: SyntaxError: assignment expression cannot be used in a comprehension iterable expression
Here is something really cursed. Try running
print(False == False in [False])
It's a classic
Output from the print: ||True||
Operator precedencd
Kinda. But both ```py
print((False == False) in [False])
print(False == (False in [False]))
print False
!e
print('eq is ran')==print('2') in [print('list')]
@unreal echo :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | eq is ran
002 | 2
003 | list
Ye
I'm not sure what the point of that code is. This is too cursed to simply be explained by operator precedence
!e
print( False == False in [False] )
print((False == False) in [False] )
print( False == (False in [False]))
@distant salmon :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | True
002 | False
003 | False
you just broke my brain
the explanation I found is that it does this
(False == False) and (False in [False])```
Yes
I wonder if anyone has actually intensionally used this "feature"
I am gonna now
>>> [_ for _ in[(__:=[...]), ...]]
File "<stdin>", line 1
SyntaxError: assignment expression cannot be used in a comprehension iterable expression
>>> ```why though?
it shows up somewhat often in golfing as a way to chain together checks
Never seen == and in be chained together in codegolf
I know of doing things like
n>1<f(n-1)
to only call f if n>1
i've seen stuff like 0<x in[some list comp]
!epy eval(''.join((__:=[chr(_+95)for _ in[*([0]*2),10,14,17,16,19,21,*([0]*2)]])+[chr(_+95)for _ in[~54,~55,*([0]*2),9,6,*([13]*2),16,*([0]*2),~55,~53]]+[''.join([chr(_+95)for _ in[~48,14,2,10,15,~54,~53]])if eval(''.join(__+[chr(_+95)for _ in[~54,~55,20,26,20,~55,~53]])).version_info.minor>10 else'']))
@arctic skiff :white_check_mark: Your 3.12 eval job has completed with return code 0.
Hello world!
print("Hello".encode())
!e
hi = "Hello".encode()
print(hi)
H
!e
hi = "Hello".encode()
print(hi)
@dire spade :white_check_mark: Your 3.12 eval job has completed with return code 0.
b'Hello'
!e
print(*b'Hello')
@wheat river :white_check_mark: Your 3.12 eval job has completed with return code 0.
72 101 108 108 111
yeah because := is 3.8+
a flappy bird clone I wrote a while ago for a jam (requires pygame(-ce))
from time import*
from pygame import*
init()
d=display
c=draw.rect
r=Rect
t=l=j=0
while not event.get(256):
s=d.set_mode((500,300));event.clear();k=key.get_pressed()
if l:
if t%66==0:o+=[m:=r(550,y:=time_ns()%11*-20,50,200),m.move(0,300)]
j+=1;p.y+=min(j,9);c(s,-1,p);t+=1;l=p.collidelist(o+[(0,0,70,300)])==len(o)
for a in o:a.x-=3;c(s,-1,a)
if k[32]:j=-8
else:s.blit(Font().render(str(t),(l:=k[13])and(t:=0),"red"),p:=r(40,90,10,10));o=[]
o=o[-6:];d.flip();time.wait(33)
(it was TweetTweetJam8 and the goal was to fit a game within 500 characters of code, mine is 499)
i believe removing r=Rect will save a char
only two r usages, huh, alr, nicely spotted
t%6==0 is the same as t%6<1
y:=time_ns()%11*-20 is not being used after, so you can remove y:=
else:s.blit(Font().render(str(t),(l:=k[13])and(t:=0),"red"),p:=r(40,90,10,10));o=[]
else:s.blit(Font().render(str(t),0,"red"),p:=r(40,90,10,10));o=[];l=k[13];t=0
str(t)
f'{t}'
I don't see the purpose of y to begin with. It is never used, right?
if k[32]:j=-8
j=[j,-8][k[32]]
``` same amount, if you move `j=[j,-8][k[32]]` to other statements
yes
so y+=min(j,9) could just be removed
it is p.y+=...
it is moving the player
r(40,90,10,10) -> r(40,90,9,9)
shrink player by 1px and save 2 chars 🙂
you can also remove ;t=0 in the "init" code
it will possibly shift columns a bit, but i dont think it is significant
o=o[-6:]; is not important
i doubt anyone will run out of memory because of infinite number of rects
# if k[32]:j=-8
j-=k[32]*2
``` this change makes game a lot funnier
you can merge it with j+=1 and save another couple of chars
from time import*
from pygame import*
init()
d=display
c=draw.rect
r=Rect
t=l=j=0
while not event.get(256):
s=d.set_mode((500,300));event.clear();k=key.get_pressed()
if l:
if t%66<1:o+=[m:=r(550,time_ns()%11*-20,50,200),m.move(0,300)]
j=[j+1,-8][k[32]];p.y+=min(j,9);c(s,-1,p);t+=1;l=p.collidelist(o+[(0,0,70,300)])==len(o)
for a in o:a.x-=3;c(s,-1,a)
else:s.blit(Font().render(str(t),0,"red"),p:=r(40,90,9,9));o=[];l=k[13]
d.flip();time.wait(33)
``` 456
not sure what event.clear(); was doing
i removed it and everything seems fine
it was important 🤦♂️
removing it broke score resetting
i also tried to remove init() by doing set_mode before other stuff (it inits some parts of pygame internally)
but it doesnt initialize fonts, so it didnt work
from time import*
from pygame import*
init()
d=display
c=draw.rect
t=l=j=0
while not event.get(256):
s=d.set_mode((500,300));k=key.get_pressed()
if l:
if t%66<1:o+=[m:=Rect(550,time_ns()%11*-20,50,200),m.move(0,300)]
j=[j+1,-8][k[32]];p.y+=min(j,9);c(s,-1,p);t+=1;l=p.collidelist(o+[(0,0,70,300)])==len(o)
for a in o:a.x-=3;c(s,-1,a)
else:s.blit(Font().render(str(t),0,"red"),p:=Rect(40,90,9,9));o=[];l=k[13];t=0
d.flip();time.wait(33)
``` 445
this is also completely wrong 🤦♂️
tried to apply same idea, but saved only one char:
# 427
from pygame import*
init()
d=display
c=draw.rect
t=l=j=0
while not event.get(256):
s=d.set_mode((500,300));k=key.get_pressed()
if l:
if t%66<1:o+=[m:=Rect(550,p.y%9*-25,50,200),m.move(0,300)]
j=[j+1,-8][k[32]];p.y+=min(j,9);c(s,-1,p);t+=1;l=p.collidelist(o+[(0,0,70,300)])==len(o)
for a in o:a.x-=3;c(s,-1,a)
else:s.blit(Font().render(str(t),(l:=k[13])and(t:=0),"red"),p:=Rect(40,90,10,10));o=[]
d.flip();time.wait(33)
# 426
from pygame import*
init()
d=display
c=draw.rect
x=t=l=j=0
while not event.get(256):
s=d.set_mode((500,300));k=key.get_pressed()
if l:
if t%66<1:o+=[m:=Rect(550,p.y%9*-25,50,200),m.move(0,300)]
j=[j+1,-8][k[32]];p.y+=min(j,9);c(s,-1,p);t+=1;l=p.collidelist(o+[(0,0,70,300)])==len(o);x=t
for a in o:a.x-=3;c(s,-1,a)
else:s.blit(Font().render(str(x),0,"red"),p:=Rect(40,90,10,10));o=[];t=l=k[13]
d.flip();time.wait(33)
also from time import* is removed, random columns are generated by p.y%9*-25 instead of time_ns()%11*-20
oh, using -1 to produce white color is smart
w=input().upper()
print("Impossible"if w[0]in"AEIOU"else w[1:]+w[0]+"UM")```
how would you golf it further?
if first letter is a vowel print impossible, if not, print the word with the first letter at the end + "UM"
a if b else c can usually be improved by doing [c,a][b]
!e
w="Latin".upper()
print([w[1:]+w[0]+"UM","Impossible"][w[0]in"AEIOU"])
@bright valve :white_check_mark: Your 3.12 eval job has completed with return code 0.
ATINLUM
nice
eh, it's more so important semantically, to prevent the event queue from filling up, not sure how many events it can take, but if it fills up, it could crash
it's supposed to be as much a full game as possible
ok, i didn't know that
i never used .get(etype), only .get(), and i believe you dont have to clear event queue in that case
j=[j+1,-8][k[32]] can further be shortened to j=-[~j,8][k[32]]
yep
it removes all the events you're getting
wee meet again
!e
while True: print((lambda ch, d: ((d.update({'m1':[], 'm2':[], '+':[[],[]], '-':[[],[]]})), [(d['m1'].append([int(i) for i in list(input(f"m1 line {i}:").replace(" ", ''))])) for i in range(2)], [(d['m2'].append([int(i) for i in list(input(f"m2 line {i}:").replace(" ", ''))])) for i in range(2)], ([d['+'][i].extend([j+d['m2'][i][0], k+d['m2'][i][1]]) for i,(j,k) in enumerate(d['m1'])]), ([d['-'][i].extend([abs(j-d['m2'][i][0]), abs(k-d['m2'][i][1])]) for i,(j,k) in enumerate(d['m1'])]), ("Sum:\n" + " ".join([str(i) for i in d['+'][0]]) + '\n' + " ".join([str(i) for i in d['+'][1]]) + '\n' + 'Difference:\n' + " ".join([str(i) for i in d['-'][0]]) + "\n" + " ".join([str(i) for i in d['-'][1]]))) if ch=='a' else (((d.update({'tm':[]})), [(d['tm'].append([int(i) for i in list(input(f"line {i}:").replace(" ", ''))])) for i in range(2)], (d.update({'tf':[[d['tm'][j][i] for j in range(2)] for i in range(2)]})), ("Original:\n" + " ".join([str(i) for i in d['tm'][0]]) + '\n' + " ".join([str(i) for i in d['tm'][1]]) + '\n' + 'Transpose:\n' + " ".join([str(i) for i in d['tf'][0]]) + "\n" + " ".join([str(i) for i in d['tf'][1]]))) if ch == 'b' else (quit() if ch=='q' else (None,'Invalid Input'))))(ch=input("Enter Choice:\n(A)For Sum and Difference\n(B)For Transpose\n(Q)To Quit\n>>>").lower()[0], d={})[-1])
where @night quarry ?
also why does your code have lots of whitespaces
though can you tell what does this do?
