3 ms·
Why the Sad Face?
- BugsJustFindMe 6y ago> Sure, the disadvantage of the "sadface dedent" is that it looks alien on first encounter. It’s weird. Not to me! I love it and was doing it before I discovered Black and am immensely grateful for just about every formatting decision that Black makes (except sometimes I wish lists of function parameters didn't get split out one per line as soon as they run longer than a line, but that's extremely minor and I agree with why Black does it). In general Black's format rules just make sense where so many others (like pep8's 79 character line) do not. Often asking an organization to dictate a coding style guide is like pulling teeth (painful), but I've never had any challenges when proposing Black because it works in a way that makes life nicer for literally everyone and justifies each of its actions with a really good reason.
- ahurmazda 6y agoI will admit that I wont have a good reason to hate it but here I am. Maybe its the juxtaposition of the `)` with `:`. Most other examples end with just the former, `)`. The moment you add the colon, something just does not feel quite right. Then again this is not the hill I choose to die on.
- musicale 6y agoThe reason I like Python's significant indentation is that it saves vertical space. In contrast, sad-face dedent wastes a line every time it's used.
- qwertyB 6y agoThe effbot takes down his Python pages, and this is what is being discussed now. Sic transit gloria mundi.
- wodenokoto 6y agoThese are good arguments, but my peeve with this is, that once a line reaches the same indent as, say a function definition, it visually looks like the function is defined at that step. def f(x): Pass # visually inside def f( X # visually inside ): # visually outside of function pass
- BugsJustFindMe 6y agoThat example isn't quite how Black works, because Black only separates parentheses from their contents if the contents would be longer than a single line. So any function with one line of arguments will look exactly like your first example. I think also that the comments you put there are mistaken because functions have more logical sections than you're recognizing here. Function definitions always follow the form `<label>(<arguments>): <body>`. You say "visually inside" in two of your comments, but in actuality they are two different things entirely because one is talking about the body section and one is talking about the arguments section, and your first example just skips over the arguments section as if it either doesn't exist or isn't its own very important part of the function definition. A more thorough example set without yet expanding the arguments would be: def f(x # inside of arguments section): # outside of arguments section Pass # inside of body section vs def f( X # inside of arguments section ): # outside of arguments section pass # inside of body section or if one prefers to make the "outside" parts nonexplicit, def f(x # inside of arguments section): Pass # inside of body section vs def f( X # inside of arguments section ): pass # inside of body section The indent+dedent says "this is the section". But again, Black only does anything if your argument section runs longer than a single line. It's really not about def f(x), because Black does exactly the thing you want for f(x). It's about def f(abesessefe, dedddf_asdf, readfsefsef_afsefse, foreard_aree_aers=True, arese_mars_mares=None, maresd_des_reeebo='17'): pass vs def f( | abesessefe, | dedddf_asdf, | readfsefsef_afsefse, | foreard_aree_aers=True, | arese_mars_mares=None, | maresd_des_reeebo='17' ): pass The point of what Black does is that in the second case the dedented section terminator `)` is always going to be at the same column as the def if the arguments run past one line, so it will always be easy to find and your arguments will also be a lot easier to read.