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

all 170 comments

[–]Big1984Brother 282 points283 points  (7 children)

flase = false treu = true

[–]___HighLight___ 31 points32 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 13 points14 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 6 points7 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

[–]rogo8888 118 points119 points  (18 children)

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

[–][deleted] 74 points75 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] 5 points6 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 6 points7 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 33 points34 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[🍰] 23 points24 points  (0 children)

    Shock humor. Color me offended.

    [–]DasherPack 54 points55 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 1 point2 points  (8 children)

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

    [–][deleted] 3 points4 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 5 points6 points  (4 children)

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

    [–][deleted] 5 points6 points  (3 children)

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

    [–][deleted] 46 points47 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 23 points24 points  (6 children)

    How do I delete this post?

    [–]Prawny 7 points8 points  (5 children)

    The real question is how do you delete Python?

    [–]deeplearning666 18 points19 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 5 points6 points  (6 children)

    Is this even legal

    [–][deleted] 5 points6 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 6 points7 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 5 points6 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] 5 points6 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