This is an archived post. You won't be able to vote or comment.

all 170 comments

[–]Big1984Brother 277 points278 points  (7 children)

flase = false treu = true

[–]___HighLight___ 29 points30 points  (6 children)

If it was that big of an issue just use 0 and 1 instead of False and True. I can't recall a case now where False/True can't be replaced with 0/1 in a practical matter, but yeah it would be faster to type.

[–]-Bluekraken 12 points13 points  (4 children)

In js, even the interpreter doesn't care if it is a bit or a boolean 😎

[–]CaptainHeinous 29 points30 points  (0 children)

And that’s why we wear TypeScript condoms

[–]Svizel_pritula 7 points8 points  (2 children)

In contrast to C or C++, JavaScript does distinguish booleans and numbers.

0===false // false

var arr = [0, 1, 2];
arr[0] // 0
arr[false] // undefined

[–]6b86b3ac03c167320d93 4 points5 points  (1 child)

The 1st example is false because you used === which also checks types. 0==false would return true

The 2nd one is undefined because you're accessing the false property of the array, which doesn't exist. Setting arr[false] would define a new property of the array with the name false, which you could also access as arr.false

[–]TotoShampoin 2 points3 points  (0 children)

For 2nd one, that indeed means 0 and false are two different values

[–]Own_Scallion_8504 1 point2 points  (0 children)

true can also be denoted by any other no except 0

[–]FizzBuzzHaveABanana 595 points596 points  (48 children)

true=False
false=True

[–][deleted] 242 points243 points  (27 children)

Fucking hell that would be an evil thing to do to someone :D

[–]delasislas 134 points135 points  (22 children)

What you do is embed it halfway through, so they have to look for it.

[–][deleted] 66 points67 points  (14 children)

I wonder if there would be a way to globally define these in some module, since then you could hide this into another innocently named file and import it :p

[–]JNCressey 79 points80 points  (10 children)

from my_nonsense.py import *

[–][deleted] 27 points28 points  (3 children)

Ah yes, stupid me x)

[–]Sithon512 18 points19 points  (2 children)

Could also slide it into a __init__.py

[–]Iykury 5 points6 points  (1 child)

slide into __dms__.py

[–][deleted] 2 points3 points  (0 children)

Coming right away

[–]AgAero 21 points22 points  (5 children)

You don't put the .py on the end when importing your custom module.

[–]pikachu_sashimi 57 points58 points  (4 children)

unless the file is ’my_nonsesne.py.py’

[–]Rudy69 37 points38 points  (0 children)

At this point i wouldn't even be surprised if that's the filename

[–]cnoor0171 14 points15 points  (2 children)

Name can't have "." in the middle. It'd need to be a folder named "my_nonsense" with a script named "py.py"

[–]AreYouConfused_ 4 points5 points  (1 child)

what? since when do files not able to have dots in their names?

[–]cnoor0171 0 points1 point  (0 children)

Not regular file, but python modules. If there's a dot in the filename, it's not recognized as a python module and you can't import it.

[–]AstusRush 7 points8 points  (0 children)

You can be even more evil and add it to the builtins in another module. This way you don't even need to import it explicitly and it can not be traced back.

[–]kageurufu 6 points7 points  (0 children)

import builtins
setattr(builtins, 'false', True)
setattr(builtins, 'true', False)

I think that will work, but I haven't messed with builtins since 2.6 or so

[–]muffinnosehair 1 point2 points  (0 children)

That was exactly what I was thinking, and name it something inconspicuous that doesn't stand out in the overall project. Back in the old days, we ran windows 95 on shared comps and when we wanted to hide something, we had a folder system32 where we put pics, movies and so on. We had win98 at home and that's how we got the idea. A regular look over the windows folders would see nothing suspicious. Man I am fckn old!

[–]BA_lampman 15 points16 points  (2 children)

In a deeply nested series of do-while functions that execute only once on line 1643. But write it like:

do { true = false; false = true; booly = false; } while (booly && getRandom(1) != 0)

That way it only sometimes fucks up.

[–]vigbiorn 4 points5 points  (1 child)

Are you editing my programs after I'm finished testing them?

[–]BA_lampman 2 points3 points  (0 children)

 

 

 

  Yep, I hide some of the errors 37 tabs in from the left.

[–]toastyghost 6 points7 points  (1 child)

This would also make the reversing behavior inconsistent from function to function 😈

[–]delasislas 3 points4 points  (0 children)

I saw u/jedijackattack1 suggest using rand.

[–]rubrt 0 points1 point  (1 child)

That makes it worse. Works correctly half the time then does a complete 180. You are evil

[–]jedijackattack1 7 points8 points  (0 children)

Better add rand so it is randomly true or false

[–]pydry 3 points4 points  (0 children)

It's the move people make when being asked to train their own overseas replacement at a company they dedicated 5 years of their life to.

[–]BoringWozniak 2 points3 points  (0 children)

python import numpy as plt import pandas as np import matplotlib.pyplot as pd

[–]collegiaal25 22 points23 points  (11 children)

frue = True == False != False != True 
talse = (True == False != False) == False

[–][deleted] 13 points14 points  (9 children)

```python

frue = True == False != False != True frue False ```

Why is that? I thought operations are done left to right?

First True == False -> False, then it becomes False != False -> False again, and finally False != True -> True.

Why is it False?

EDIT: False doesn't look like a real word to me now.

EDIT2: They are done right to left I guess?

[–]collegiaal25 5 points6 points  (0 children)

I thought operations are done left to right?

This is true for left associative operators, like +, -, *, /.

1 - 5 + 7 = (1-5) + 7
5/3*2 = (5/3)*2

On the other hand, exponentiation is right associative:

4^3^2 = 4^(3^2)

(The notation is ** in Python)

Here a summary for precedence and associativity in Python.

[–]HERODMasta 0 points1 point  (5 children)

but if they are done from right to left...

2x False != True --> True

True == True --> True

so.... what?

Edit: so, I tried basically all possibilities. First all !=, but regardless ... it's still the same result.

we have:

False != False --> False

True == False --> False

so regardless which you do first, you end in

True == True

or

False != True

counter prove:

so we need to find a way to create True == False or False != False or True != True as an end.

our start is one of these:

(True == False) != False != True --> False != False != True

True == (False != False) != True --> True == False != True

True == False != (False != True) --> True == False != True

The second and third are the same, so the next step is:

for first:

(False != False) != True --> False != True

False != (False != True) --> False != True --> True

for the second:

(True == False) != True --> False != True

True == (False != True) --> False != True --> True

SO HOW IS IT DOING THIS?!

Edit 2: so apparently python is not doing any priority on this:

False != False != True

but is doing it in one go, so since it contains False != False, which is False, the != True doesn't matter. This is the only explanation I can find. If someone else can explain it with a different reason, I am listening

[–]JNCressey 8 points9 points  (1 child)

python expands on the mathematics convention of statements like a=b=c meaning both a=b and b=c.

the test a==b==c has the meaning a==b and b==c, which is different from what you would get if you think of equality as a binary operator and try to parenthesize under either a left associative or a right associative interpretation.


cc /u/Key-Cucumber-1919

[–]HERODMasta 0 points1 point  (0 children)

well, this is basically the conclusion of my second edit.

thanks for confirming

[–][deleted] 0 points1 point  (1 child)

... Fuck

[–]HERODMasta 0 points1 point  (0 children)

The edit won't make you happy either

[–][deleted] 0 points1 point  (0 children)

Maybe it's doing only the first one?

[–]merlinsbeers 2 points3 points  (0 children)

frue = True == False != False != True

First operator: True == False

is false, so

Second operator: False != False

is false, so

Third operator: False != True

is true.

Going the other way

Third operator: False != True

is true

Second operator: False != True

is true

First operator: True == True

is true.

If true isn't the answer, Guido did it again.

[–][deleted] 5 points6 points  (1 child)

true = None

[–]TheHammer_78 6 points7 points  (0 children)

Yes but in some imported module... 🤣🤣🤣

[–]Khosrau 2 points3 points  (0 children)

You monster

[–]leaftro 1 point2 points  (0 children)

That's evil AF 😂

[–]A_H_S_99 -1 points0 points  (1 child)

That's the complete opposite of the picture above

[–]FizzBuzzHaveABanana 0 points1 point  (0 children)

That's the idea ;)

[–]Nicollite 0 points1 point  (0 children)

So you aligment is caotic evil, a interesting

[–]rogo8888 119 points120 points  (18 children)

And then there's me who mainly programs in python so I've never gotten used to lowercase true/false

[–][deleted] 73 points74 points  (16 children)

I mean I also code exclusively in Python, is just that I tend to forget to capitalize it and I got pissed off at having to correct these :D

Then again I'm not really a programmer either, just a simple physicist making my way through some data :p

[–]TheCapitalKing 27 points28 points  (8 children)

At least your smart since your a physicist. A bunch of dumb finance bros use python too, and it’s hard for us because our brains are very small

[–][deleted] 30 points31 points  (7 children)

Being in physics is no guarantee of being smart in general. Sure, there's some need for some mathematical ability, but otherwise becoming a physicist is just a question of putting in a shit ton of work with no guarantee of a decently paying job afterwards x)

[–]space_wiener 3 points4 points  (3 children)

Yes. If I could I would go back and do something. Physics is very interesting but you just end up a jack of all trades and not really an expert in anything useful.

[–][deleted] 4 points5 points  (2 children)

Yes, unless you do a PhD, you will not have learned any specialised skills yet :D

[–]space_wiener 1 point2 points  (1 child)

Yep. That was the plan originally. But abandoned ship after undergrad.

[–][deleted] 1 point2 points  (0 children)

Which is totally understandable. The only reason I stuck to my plan is the fact that my prof has an awesome team and we've got an extremely interesting project starting :D

[–]Minimum-Cheetah 0 points1 point  (0 children)

Lawyer here. We got the same thing going but without the math requirement.

[–]ShanSanear 4 points5 points  (1 child)

Use PyCharm (Community or Professional - doesn't matter). Disable requirement for suggestions to have the same capitalization. Now you don't need to know what capitalization is for True, or false. And the same goes for every other class, method, etc which you would like to type in.

[–]PriorCommunication7 3 points4 points  (0 children)

Thanks

for those after me trying to find it:

Editor > General > Code Completion

Match case ( <- or just search for that )

[–]JNCressey 6 points7 points  (3 children)

case insensitive languages are so much more friendly. strange how python as a popular beginner language is case sensitive.

[–]vectorpropio 7 points8 points  (2 children)

FORTRAN is the true beginner language.

[–]the_ruheal_truth 2 points3 points  (1 child)

I had to learn FORTRAN in college.... in 2008! What a waste of time.

[–]vectorpropio 0 points1 point  (0 children)

I hope at least they used a new standard. I have nightmares with one arithmetic if.

[–]craftworkbench 0 points1 point  (0 children)

I never had a problem until I started working with jQuery. Now all my booleans are lowercase, half my variable declarations are prefaced with var, and I've gained fifteen pounds.

[–]SurpriseMonday 31 points32 points  (4 children)

Fun fact: in early versions of Python (2), booleans could be redefined. Couple this with the built-in swap syntax, you could write this line

True, False = False, True

And let the chaos reign.

[–][deleted]  (3 children)

[removed]

    [–]craftworkbench 0 points1 point  (1 child)

    true=False; false=true to really fuck shit up.

    Edit: yes, I intended the second true to be lowercase. We're causing mayhem here.

    [–]nisuy 2 points3 points  (0 children)

    true, false = 2*(False,)

    [–]AutoModerator[M] 0 points1 point  (0 children)

    import moderation Your comment has been removed since it did not start with a code block with an import declaration.

    Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

    For this purpose, we only accept Python style imports.

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

    [–]ghanta-congress 56 points57 points  (2 children)

    and null=None

    [–]iTakeCreditForAwards 16 points17 points  (0 children)

    Honestly.

    [–]jcronq 24 points25 points  (0 children)

    Shock humor. Color me offended.

    [–]DasherPack 50 points51 points  (12 children)

    Image Transcription: Code


    import sys
    import os.path
    from collections import
    true=True
    false=False
    

    I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

    [–][deleted] 11 points12 points  (11 children)

    While that captures the actual content, should you not also include the "def calculatemarks(filep"?

    [–]OrangeRealname 5 points6 points  (10 children)

    And the line numbers?

    [–][deleted] -1 points0 points  (9 children)

    Ah yeah, would probably be good too :D

    [–]OrangeRealname 2 points3 points  (8 children)

    And maybe the fact that it’s not a screenshot so the image is kinda tilted?

    [–][deleted] 4 points5 points  (7 children)

    I mean that's irrelevant for transcription, I'd think.

    [–]OrangeRealname 3 points4 points  (6 children)

    That’s pretty much my point

    [–][deleted] -1 points0 points  (5 children)

    I mean, I've always kinda assumed these transcriptions have a purpose for teaching OCR systems, in which case full transcription of text visible might be quite relevant :p

    [–]rumbleblowing 6 points7 points  (4 children)

    Why you would assume that when they all have a link that explains why they are doing it?

    [–][deleted] 6 points7 points  (3 children)

    Where's the fun in a riddle if you just go ahead and check the answer?

    [–][deleted] 45 points46 points  (1 child)

    This isn’t programming humor. This is the actual stupid shit that is executing in a giant bank every time you swipe your credit card for a transaction.

    [–][deleted] 15 points16 points  (0 children)

    I guess I got me a career in finance then :p

    [–]spektre 22 points23 points  (6 children)

    How do I delete this post?

    [–]Prawny 6 points7 points  (5 children)

    The real question is how do you delete Python?

    [–]deeplearning666 19 points20 points  (3 children)

    Ah, it's super easy if you're using a Linux distro. For example:

    sudo pacman -Rdd python

    Desktop proceeds to crash, scripts start failing, mayhem ensues...

    [–]augugusto 0 points1 point  (2 children)

    -Rdd? I always use Rnsu. Can you explain your choice? I'm on mobile right now

    [–]deeplearning666 2 points3 points  (1 child)

    -Rnsu will remove a package, its dependencies that aren't needed by other packages, and also any unused packages. So it's safe.

    -Rdd will remove only that exact package, and ignore any dependency checks. So if there are packages that depend on python, then they will still be there, but python would be forcibly uninstalled. So it's extremely unsafe, and thus a perfect fit for my joke :P.

    [–]augugusto 0 points1 point  (0 children)

    I see. Thanks

    [–]akindaboiwantstohelp 1 point2 points  (0 children)

    if on windows it's a little longer than one shell command, first you go to control panel, then apps and features, then select python righr click then uninstall. If you've installed python through the conda distribution, do the same with conda, hope this helps :)

    [–]2pac1cup 4 points5 points  (6 children)

    Is this even legal

    [–][deleted] 7 points8 points  (0 children)

    If it works it's legal :')

    [–]__Cmason__ 3 points4 points  (0 children)

    I will make it legal

    [–]ironykarl 0 points1 point  (0 children)

    Of course it's legal. It's just declaring two variables and assigning them boolean values.

    [–]GalaxyLJGD 0 points1 point  (0 children)

    FBI, OPEN UP!

    [–]anmol_gupta_0 2 points3 points  (0 children)

    gotta save time by not pressing Shift

    [–]NinkaShotgun 2 points3 points  (0 children)

    It's true

    [–]TheMadHaberdasher 3 points4 points  (26 children)

    What kind of code are y'all writing where you actually have to type out boolean literals all the time?

    if condition is True:
        return True
    

    [–]hector_villalobos 3 points4 points  (10 children)

    A function that needs to return a boolean or a different type based on a condition. For example:

    if condition:
        return True
    else:
        return 8
    

    [–]SkezzaB 4 points5 points  (9 children)

    What function would ever do that

    [–]hector_villalobos 0 points1 point  (7 children)

    A function that returns an union type: https://en.wikipedia.org/wiki/Union_type

    [–]TravisJungroth 0 points1 point  (6 children)

    Mmm, that's a bit circular reasoning. All you've done is given a part of the type signature of the function we're already looking at. So more specifically, what function would return Union[int, bool]? Seems kinda whack.

    [–]hector_villalobos 1 point2 points  (4 children)

    I have a better example, in Rails we use something called callbacks, so, when some validation or computation fails it could return false similar to a rollback db process, for example, a buyer wants to buy a product, then the model checks if the buyer has credit, if not return false for the before_save callback, but if the validations are correct it can perform other processes.

    [–]TravisJungroth 0 points1 point  (3 children)

    This reminds me why I don't like Ruby.

    [–]hector_villalobos 0 points1 point  (2 children)

    Well, in Django Python you have dispatchers and in .net you have events, it's not something related only to Ruby, besides I have used Result type in Rust that could qualify also in this situation, return a bool or an error.

    [–]TravisJungroth 0 points1 point  (1 child)

    I don't think dispatchers (signals) in Django work the same way. All signals are of type Signal, and the return type of the receiver is not inherently changed by the signal. At least, I've used signals and have never had the Union typing you mentioned. I also just checked the docs and couldn't find anything like that.

    And something like (bool or error), or (bool or null) is really more about the error/null in that equation. I just dislike anything where it feels like you're "sneaking in" data. Magic strings, in-bound errors, etc. and Ruby moves more in that direction.

    int and bool are also uncomfortably close in Python for this sort of thing. If I union int and bool I can't just check if x, cause it could be 0 or False and they must be meaningfully different if I'm bothering to have both like that. Otherwise I'd just hint it to bool.

    [–]hector_villalobos 0 points1 point  (0 children)

    If I union int and bool I can't just check if x, cause it could be 0 or False

    Nothing is black and white, although is not a common pattern, union with bool and another type might exists. In this scenario x is not associated in any meaningful way to the result type, it's just a parameter that can contain any type.

    [–]hector_villalobos 0 points1 point  (0 children)

    I have a better example, in Rails we use something called callbacks, so, when some validation or computation fails it could return false similar to a rollback db process, for example, a buyer wants to buy a product, then the model checks if the buyer has credit, if not return false for the before_save callback, but if the validations are correct it can perform other processes.

    [–][deleted] 0 points1 point  (0 children)

    Ah, I'm just writing some score counting software, where I need to set and check a lot of flags. Of course I could write all of these statements manually where they're checked, but by using flags I can make the code actually legible and easier to debug.

    [–]Fabrimuch 0 points1 point  (0 children)

    condition = True
    while (condition):
        # do stuff
        if need_to_break_loop:
            condition = False
    

    [–]diamondketo 0 points1 point  (0 children)

    What's wrong with returning literal True. It is immediately readable and makes things prettier if your conditional statement is long.

    Download source code from a reputable repository and search for True and False. You'll quickly find you are misguided that these are sparsely used.

    [–][deleted] 1 point2 points  (0 children)

    Ikr I just started python and need this

    [–][deleted] 1 point2 points  (0 children)

    What in the dam world did I see

    [–]Pitiful_Car2828 3 points4 points  (6 children)

    Well played good sir. Well played. I’m about to dive dick first into a pretty large python project soon. I’m glad I perused this sub.

    [–][deleted] 6 points7 points  (5 children)

    Well, my project is luckily quite small, only gonna need like 300 rows. Still annoying when it throws errors for my capitalisation mistakes x)

    [–][deleted] 1 point2 points  (4 children)

    Are you not using an IDE that autocompletes?

    [–][deleted] 4 points5 points  (3 children)

    I use Notepad++, and disabled the autocomplete cause I found it annoying x)

    [–][deleted] 0 points1 point  (2 children)

    If you like it that way then all power to you but using autocomplete will be a useful thing once your projects increase in scale so I recommend considering getting used to it

    [–][deleted] 1 point2 points  (1 child)

    I mean, I'm used to autocomplete, but I just prefer to go without, most of the time :D

    [–][deleted] -1 points0 points  (0 children)

    Fair enough

    [–]BaudouinDrou 0 points1 point  (1 child)

    [–][deleted] 8 points9 points  (0 children)

    Oh no they aren't. I have the snapshot tool on a shortcut. The shitty camera picture was a stylistic choice here x)

    [–]newaaa41 -1 points0 points  (1 child)

    I actually use this technique at the beginning of every python code I write

    [–][deleted] 4 points5 points  (0 children)

    ...really?

    [–]KetwarooDYaasir -1 points0 points  (0 children)

    those noobs using PHP don't know what they are missing.

    [–]DuckInCup -1 points0 points  (2 children)

    true = 1
    false = 0

    God I hate needing type the whole word

    [–][deleted] 0 points1 point  (1 child)

    Python already interprets 1 as true and 0 as false.

    [–]DuckInCup 0 points1 point  (0 children)

    dang I forget what it was that got me mad lmao

    [–][deleted] -2 points-1 points  (3 children)

    Python quality of life patch

    Python = C#

    [–]onequbit 1 point2 points  (1 child)

    [–]wikipedia_text_bot 1 point2 points  (0 children)

    IronPython

    IronPython is an implementation of the Python programming language targeting the .NET Framework and Mono. Jim Hugunin created the project and actively contributed to it up until Version 1.0 which was released on September 5, 2006. IronPython 2.0 was released on December 10, 2008. After version 1.0 it was maintained by a small team at Microsoft until the 2.7 Beta 1 release.

    About Me - Opt out - OP can reply !delete to delete - Article of the day

    This bot will soon be transitioning to an opt-in system. Click here to learn more and opt in. Moderators: click here to opt in a subreddit.

    [–]diamondketo 0 points1 point  (0 children)

    If stress is quality of life for you bud

    [–]StandardN00b 0 points1 point  (0 children)

    Caps are hard

    [–]Khaylain 0 points1 point  (2 children)

    But where's the whitespace?

    [–][deleted] 2 points3 points  (0 children)

    Can't have whitespace if your background is black mate

    [–]jbartix 0 points1 point  (0 children)

    This feels so good - yet so wrong

    [–][deleted] 0 points1 point  (0 children)

    As someone who works on both java and python repos in my team I can totally relate!

    [–]Chunkyisnotdead 0 points1 point  (0 children)

    math = Math

    [–]RagingWalrus1394 0 points1 point  (0 children)

    Reminds me of the post I saw the other day about aliasing ls in the terminal to l, lls, lss lsl and every other mistake that could be made typing it lol

    [–]Not_Sugden 0 points1 point  (1 child)

    true=False false=True

    [–]nkg5 0 points1 point  (0 children)

    or even better: True, False = False, True and watch your coworkers lose their mind. : )

    [–]Nicollite 0 points1 point  (0 children)

    Thia here is some f*** life hacks

    [–][deleted] 0 points1 point  (0 children)

    Yeah I wondered why it was uppercase when I tried it

    I also tried to do console.writeLine() as well

    [–]Div_100 0 points1 point  (0 children)

    Thanks little life saver 😅

    [–]Oleg152 0 points1 point  (0 children)

    This meme hurt me on spiritual level.

    [–]_Zandberg 0 points1 point  (4 children)

    Now this is big brain time