Mom, can we stop and get some Python?
No, we have Python at home.
Python at home…
What if I prefer this?
#define CURLYOPENRIGHTCLOSEDLEFTBRACKET { #define CURLYOPENLEFTCLOSEDRIGHTBRACKET } #define CURVYOPENRIGHTCLOSEDLEFTBRACKET ( #define CURVYOPENLEFTCLOSEDRIGHTBRACKET ) #define PERIODWITHPERIODONTOP : #define COMMAWITHPERIODONTOP ; int main CURVYOPENRIGHTCLOSEDLEFTBRACKET CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET if CURVYOPENRIGHTCLOSEDLEFTBRACKET 1 CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET asm volatile CURVYOPENRIGHTCLOSEDLEFTBRACKET "mov $1, %%rax\n" "mov $1, %%rdi\n" "lea message(%%rip), %%rsi\n" "mov $4, %%edx\n" "syscall\n" PERIODWITHPERIODONTOP PERIODWITHPERIODONTOP PERIODWITHPERIODONTOP "%rax", "%rdi", "%rsi", "%rdx" CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP CURLYOPENLEFTCLOSEDRIGHTBRACKET return 0 COMMAWITHPERIODONTOP CURLYOPENLEFTCLOSEDRIGHTBRACKET asm CURVYOPENRIGHTCLOSEDLEFTBRACKET ".section .data\n" "message: .ascii \"wut\\n\"\n" ".section .text\n" CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
You can’t be helped, sorry. We will put you to an asylum for people like you
Asylum? We have the electric chair for this.
Yeah, now I see why you want him dead. He used mov after lea
Pack him, boys: https://youtu.be/hHuLZFuugTQ
You win a free trip to the Hague
They don’t even deserve the trial. Straight to gulag.
Still need at least troyka to send to gulag. Or regular court outside of stalinism.
The taxi chauffeur can be judge and do it on the way to the gulag.
Obviously the sentence is predetermined.
Can this be done with emoji?
😫
Acceptable, just FYI I added a pre-commit git hook, please rebase your changes.
Thanks. I hate it.
Idk why but i fell in love with this and might just use it now
God
I just realised why we do live coding interviews.
Looks like Python, but in an editor with a weird TUI scrollbar
High chance that it’s a Python programmer who is really unhappy about having to work in Java, lol
Agreed. I saw this and thought it looked beautifully passive aggressive
Ha! Now I see it - that was very funny, sir!
Doesn’t python need colons after if/else/for/etc. statements?
Heh, so in Python it’s possible to overload operators in the context of objects. I bet it would be possible to overload tabs to do the same thing as colons inside a context manager, but that’s pure speculation.
Perhaps I don’t understand you, but I don’t think there’s a way to override spaces in python in any way. The spaces are handled by the parser.
You can define what happens for an object when an operator is applied (like +, /, or -) so that you can obj+obj. I wonder if there’s a way to override “tab” such that it acts like a “:”, but from inside the language (this is trivial if you edit the language itself like you suggest). Thinking about it more, I’m guessing not since “:” isn’t an operator and this doesn’t have a corresponding __operator__ function.
If Python has anything like Perl’s source code filters, then anything’s up for grabs, but Perl is kind of weird in a way that Python was specifically designed not to be. Or at least Python 1 was. Things may have changed in the intervening couple of decades.
If it’s just plain overloading, then whitespace is probably off the table. Spaces, even required spaces, aren’t so much syntax as they are structure. You could argue that the curly braces of some other languages are more syntactic than Python’s whitespace, because it’s actually Python’s magic colon and the first unindented line (lack of whitespace!) that serve that specific syntactic purpose.
Examples of Perl’s source code filters range from turning a program into binary representation of the syntax tree and still having it be executable, to new syntax, to writing programs entirely in Latin or something that looks almost but not entirely unlike it, anyway.
I see. I would love to be proven wrong, but I don’t see a way this would work with tabs/spaces in python.
IIRC, Python handles whitespace indentation by having the tokenizer convert them to INDENT/DEDENT tokens. The grammar can then handle them equivalently to a curly brace language.
You can write
FortranPython in any language.
Literally me every time I want to program something slightly complex in Python.
It’s just YAML…
YAML makes you appreciate Python’s 4 spaces indentation.
I thought python allowed whatever indentation you wanted as long as it’s consistent?
pep8 calls for 4 space but it is a guidance not a rule.
Google internal style guide recommend(ed?) 2 spaces to accomodate the line length limit.
It does, but most style guides and autoformatters will use 4
Python is one of the few languages with an official style guide, I think that guide says 4 spaces.
Tabs!
I’ve set tabs to four spaces in vim because who the fuck defaults tab to eight spaces. That shit looks alien and pushes text off the screen fast.
4 tabs is a bit overboard, don’t you think?
deleted by creator
4 spaces? Hard core Python programmers must have a callus on their thumbs.
Just assign tab to 4 spaces.
Mmmm, perfectly level.
I’d love to see your .editorconfig.
…
…
What’s that in your project root? …pom.xml? Misread that at first as porn.xml.
I’m not the OG on this, just an old reddit post I remembered
https://old.reddit.com/r/ProgrammerHumor/comments/9fhvyl/writing_yaml/
porn.xml
If I had a nickel every time I read it like that
But yaml forces the indentation
Whitespace isn’t semantically important. Ticket closed.
Growing up with C made me assume semicolons and braces were needed to avoid subtle bugs, but experience with more recent languages showed me that it’s possible to reliably parse the same semantic cues that humans use: indentation, parentheses, and other such context. (Perhaps this was less viable when C was invented, due to more constrained hardware.)
I was skeptical at first, but in practice, I have never encountered a bug caused by this approach in Python, Nim, or any other language implementing it consistently, over the course of a decade or two using them. Meanwhile, I have seen more than a few bugs caused by brace and semicolon mistakes.
So nowadays (outside of niche & domain-specific languages) I see braces and semicolons as little more than annoying noise and fuel for religious arguments.
In Java it’s quite difficult to forget semicolon and still have a syntactically correct program.
I think braces are incredibly important. With Python it can be confusing which indentation is correct when copying code between files. Different indentations can easily be still syntactically correct, but the outcome is vastly different. It’s often I have to double and triple check to verify I copied the code with correct indentation.
It’s often I have to double and triple check to verify I copied the code with correct indentation.
I vaguely remember facing that issue once or twice in the past, but certainly not often. It was because the pasted code was too long for its starting point to be easily found in my editor, even if I scrolled up a bit.
If this happens to you often, I wonder: perhaps the code you maintain should be broken into smaller functions?
If I was in that situation again, I think I would simply place a bookmark before pasting and then jump back to the bookmark to indent/dedent the pasted block appropriately.
Edit: Come to think of it, I would have to check and correct it regardless of the language and braces, since confusingly indented code is unwelcome in my commits.
Don’t you use a formatter that fixes whitespace in sloppy writing?
I’ve never needed one.
As someone used to working in c# (and before that Java, C++, Visual Basic, and Pascal) I haven’t seen any brace or semicolon related errors since the days of Borland IDEs (any remotely self respecting IDE will highlight them and refuse to compile, these days), but working with Kotlin has shown me that I, at least, read code with semicolons slightly faster than code without.
There’s a reason we use punctuation when writing, and the same applies to code.
Borland IDEs
Ugh, you just gave me Turbo Basic flashbacks. My favorite thing was that variable names could be as long as you liked and mixed case, but the compiler only used the first two letters and case insensitive at that. So “BatShitCrazy” and “BALLPARKESTIMATE” actually referenced the same variable.
It’s kinda organic in python, but God forbid how often I made mistakes in yaml learning k8s
Haha… Yes, I’ve found yaml to be problematic in this area, too. Probably because it lacks the context cues and modularity of a programming language.
Context cues could be provided by jsonschema, but still it’s unbearable in comparison even with json.
Plus any decent editor catches when lines are unreachable or in violation due to misformatting.
If not that, which seems unlikely, your unit tests would
GCC has separate warning when braces don’t match identation
Python programmer encountering a real programming language for the first time.
WE CAN DO THAT!?!??
… whitespace is whitespace.
Or you could replace most of the whitespace with repeating semicolons. Makes the code much clearer!
I low key love it. It’s unconventional, but it’s not hard to read
it’s not hard to read
Until there’s missing brace somewhere
I think this could be better for reading but harder for writing. Like you could write a script that converts between this and the easier to write way if you are working on a project with others.
On braces are not used in
if
orfor
statements
I was like, “where are the braces?”. Then, I turned to the right
And then I realized it’s python.
Wait what? It’s Python? But there are semicolons
They mean that the code is being written like it were python. You can’t get rid of the curly braces, but you can shove them all under your bed where mom can’t see.
Thank you. I couldn’t see the problem.
And if this layout is auto generated, maybe I still don’t see the problem.
This looks like a python programmer that is mad they have to write
C#Java…Pretty sure that is Java, not C#
No, you`re right.
My credo on this kind of thing is never do something that will make your successor so mad that they find out where you live and post parts of your body to Interpol.
Good fences make good neighbors.
Corollary: server-side commit hooks make good teammates.
This should be its own language. Pyava.
Or Jathon (pronounced like Mike Tyson would pronounce JSON)
Or we can round out the confusion and call it PythonScript
I kinda like it, easy to see unbalanced braces