184
Don't do it (lemmy.world)
top 33 comments
sorted by: hot top controversial new old
[-] LostXOR@fedia.io 131 points 2 weeks ago

In case anyone's curious:

not() # True
str(not()) # 'True'
min(str(not())) # 'T'
ord(min(str(not()))) # 84
range(ord(min(str(not())))) # range(0, 84)
sum(range(ord(min(str(not()))))) # 3486
chr(sum(range(ord(min(str(not())))))) # 'ඞ'
[-] devfuuu@lemmy.world 32 points 2 weeks ago

What kind of dumb language is this?

[-] LostXOR@fedia.io 43 points 2 weeks ago
[-] takeda@lemm.ee 24 points 2 weeks ago* (last edited 1 week ago)

Python, but this is actually defined and documented behavior.

Edit: to illustrate what I mean:

not() # True

this actually is not () (the lack of space makes it look like a function), () is a tuple, in python an empty collection returns False, this is to make checks simpler. You can type:

if my_list:
  do something

instead of

if len(my_list) > 0:
  do something

not negates it so you get True

str(not()) # 'True'

converts resulting bool type into a string representation

min(str(not())) # 'T'

This might feel odd, but that's also documented. min() not only allows to compare two numbers like it is in most languages, but you can also provide a sequence of values and it will return the smallest one.

String is a sequence of letters.

Letters are comparable according to ASCII (so you can do sorting). In ASCII table capital letters are first, so the 'T' is the smallest value.

ord(min(str(not()))) # 84

this just converts 'T' to Unicode value which is 84

range(ord(min(str(not())))) # range(0, 84)

This creates a sequence of numbers from 0 to 83

sum(range(ord(min(str(not()))))) # 3486

This works like min() except adds up all the numbers in the sequence together, so in our case 0+1+2+3+...+83 = 3486

chr(sum(range(ord(min(str(not())))))) # 'ඞ'

reverse of ord(), converts Unicode value to a character.

[-] nutcase2690@lemmy.dbzer0.com 31 points 2 weeks ago* (last edited 2 weeks ago)

You forgot the most important part!

print(chr(3486)) # ඞ
[-] Landless2029@lemmy.world 5 points 2 weeks ago
[-] _g_be@lemmy.world 24 points 2 weeks ago

It could be an impostor

[-] JackbyDev@programming.dev 8 points 2 weeks ago

It looks like the characters from the game Among Us.

[-] sloppysol@lemmy.world 1 points 2 weeks ago

Looks like telugu

[-] Ziglin@lemmy.world 11 points 2 weeks ago

Why does not without a parameter return True? I'm starting to like the fact that I haven't touched python in a while.

[-] LostXOR@fedia.io 23 points 2 weeks ago

I think it's because not() is equivalent to not(None), and since None is falsy not(None) returns True.

[-] takeda@lemm.ee 7 points 2 weeks ago

Are you sure?

I can't test it now, but to me it looks like () is an empty tuple. Python behavior is that for logic operations empty set equals to false. Then we apply not to get True. Not having space between not operator and parentheses makes it look like it is a function.

[-] LostXOR@fedia.io 1 points 1 week ago

I'm pretty sure you're right; that makes more sense.

[-] brb@sh.itjust.works 6 points 2 weeks ago

God I love python

[-] Ziglin@lemmy.world 5 points 2 weeks ago

Why is literally nothing equivalent to None? Is it because None is the default value of an optional parameter? (If so why oh why is it optional)

[-] spooky2092 5 points 2 weeks ago* (last edited 2 weeks ago)

Because nothing isn't something, and something is true. It's base Boolean logic where everything is either true or false. Null/nothing is false.

It's a weird way to think about conditionals, but it makes sense when you use them in real examples. In my case, I use them like this when I need to make sure that a variable has a value. So I can do something like

If(variable){do things with the variable}else{do stuff when the variable doesn't exist}

[-] Ziglin@lemmy.world 1 points 1 week ago

I understand that, it makes sense. But why does it not throw an error? The parameter is missing after all.

[-] takeda@lemm.ee 2 points 1 week ago

Actually the explanation is wrong.

not()

is actually

not ()

not is a keyword not a function.

Boolean of empty tuple is False and then not negates it.

I explained it better here:

https://lemm.ee/post/61594443/19783421

[-] Ziglin@lemmy.world 1 points 1 week ago

That makes a lot more sense, thanks I did see in the syntax highlighting that it was a keyword but forgot that none of them took parameters.

[-] spooky2092 1 points 1 week ago

No it's not, "" (a null/empty string) is the parameter. Not every function needs a parameter to be valid, and negation is one of them. Negating nothing is something, so "not()" = "not(null)" = "not(false)" = "true"

[-] humanspiral@lemmy.ca 2 points 2 weeks ago

in J, many other languages, not null is null.

[-] pupbiru@aussie.zone 3 points 2 weeks ago
a  = null
if not a:
   …

if not a were null then an if that evaluates that would evaluate it as falsy… also if a would evaluate as falsy :/ that’s far weirder behaviour

[-] ImplyingImplications@lemmy.ca 77 points 2 weeks ago

It prints Unicode character #3486: ඞ

[-] Jimbabwe@lemmy.world 33 points 2 weeks ago
[-] protist@mander.xyz 26 points 2 weeks ago* (last edited 2 weeks ago)
[-] valkyrieangela 9 points 2 weeks ago

GETOUTOFMYHEAD GETOUTOFMYHEAD GETOUTOFMYHEAD

[-] OpenStars@piefed.social 8 points 2 weeks ago
[-] eta@feddit.org 26 points 2 weeks ago

thanks I won't do that 'cause it's sus

[-] quantenzitrone@lemmings.world 23 points 2 weeks ago
>>> print(print(chr(sum(range(ord(min(str(not()))))))))
ඞ
None
[-] grrgyle@slrpnk.net 8 points 2 weeks ago
[-] Zangoose@lemmy.world 6 points 2 weeks ago

Is it bad that I already knew what this would print the moment I read the meme?

[-] ramenshaman@lemmy.world 3 points 2 weeks ago

You can't tell me what to do

this post was submitted on 17 Apr 2025
184 points (100.0% liked)

memes

14480 readers
1945 users here now

Community rules

1. Be civilNo trolling, bigotry or other insulting / annoying behaviour

2. No politicsThis is non-politics community. For political memes please go to !politicalmemes@lemmy.world

3. No recent repostsCheck for reposts when posting a meme, you can only repost after 1 month

4. No botsNo bots without the express approval of the mods or the admins

5. No Spam/AdsNo advertisements or spam. This is an instance rule and the only way to live.

A collection of some classic Lemmy memes for your enjoyment

Sister communities

founded 2 years ago
MODERATORS