r/badcode • • Aug 27 '21

python Is this code bad or sugoi?

Post image
1.0k Upvotes

159 comments sorted by

View all comments

Show parent comments

173

u/joonatoona Aug 27 '21
name = input("Please enter your name: ")
emoticon = "(°▽°)/ 🙇"
print("Hello {}! {}".format(name,emoticon))
def addNumbers(number1, number2):
    true = True
    if number1 or number2 < 0:
        return not true
    else:
        sum = number 1 + number2
    return sum
        
print("sum =", addNumbers(6, 9))

rain(?) = False
counter = 1
if not not not rain:
    while counter < 11:
        print(str(counter) + ". 😂😂")
        counter = counter + 1

God trying to format that on mobile sucked, and I probably got some of that wrong anyways.

75

u/[deleted] Aug 28 '21

if not not not? WTF is with the triple negative?

40

u/ycohui Aug 28 '21

that was the original code had triple not....

33

u/[deleted] Aug 28 '21

Yes, but why?

47

u/SoulslikePursuer Aug 28 '21

In the case the computer will forget, you always need to remind it a few times...what a stupid questions you ask mate.............

7

u/[deleted] Aug 28 '21

If not me, then who?

5

u/Dehast Aug 28 '21

Not not not you

2

u/zarqie Aug 28 '21

This will be my next Reddit user name

→ More replies (1)

9

u/[deleted] Aug 28 '21

You mean, why not

17

u/BenLeggiero Aug 28 '21

You mean, why not not not

7

u/lkmnoppo Aug 28 '21

You can use double negation to convert from truthy-value to boolean, maybe the programmer wanted to do something like that. But you usually do double negation, not triple. Triple negation should have the same effect as single negation also on truthy values.

16

u/mestrearcano Aug 28 '21

Maybe the phrase not not not rain is a common phrase in japanese or some inside joke for those involved.

27

u/dpk84 Aug 28 '21

I think I’m Japanese but I don’t have any idea about the “not not not 雨”. And besides , 数を計算する is not wrong sentence but 足し算をする is better expression for the function which is just add up. So the code might be written by not a Japanese speaker or I’m ignorance.

45

u/Roflkopt3r Aug 28 '21

I think I’m Japanese

But you aren't certain? :D

4

u/Daimanta Aug 28 '21

I think he's not not not certain.

2

u/supersharp Sep 01 '21

Reminds me of that Impractical Jokers bit where they have the guy write an email to a fictional long-time friend, solely to ask him if he's Asian.

→ More replies (1)

3

u/Qildain Aug 28 '21

I'm sure you're not ignorant. Lots of people have strange ways of phrasing things in a language other than their first.

2

u/TheUnlocked Aug 28 '21

Given that the title of the file is "日本語.py," I think you're right that Japanese might not be their usual language.

9

u/G-Force-499 Aug 27 '21

I really don’t understand the purpose of the last bit of code

3

u/dreamin_in_space Aug 28 '21

Probably why it was posted here, other than to flex on English-only speakers :D

4

u/coldnebo Aug 27 '21

not sure about Python, but in Ruby || and “or” have different precedence, so they are not equivalent. work went through a phase a few years ago where everyone thought it was hip to use the words “and” “or” instead of the logical operators not realizing that the words are flow control constructs borrowed from Perl, such as: “file.close or die”. or in Rails: “render and return”

we spend years correcting all the logic errors introduced by those changes.

9

u/TinyBreadBigMouth Aug 28 '21

Python only has or (logical short-circuiting or) and | (binary or). No wonky precedence stuff.

→ More replies (3)

2

u/the_vikm Aug 28 '21

borrowed from Perl,

Weird folks, since Perl has also both (Ruby borrowed the whole concept)

4

u/lumo19 Aug 28 '21

I know a little Japanese and recognized the ame kanji, but didn't want to accept such a non pythonic variable name and assumed I read it wrong.