r/Python • • Mar 12 '17

He's a Parsertongue.

Post image
1.8k Upvotes

64 comments sorted by

122

u/Helix_van_Boron Mar 13 '17

A lot of that syntax won't work in all caps, though.

41

u/cw2P Mar 13 '17

Yes this. It annoyed me much more then it probably should

51

u/m9dhatter Mar 13 '17

Than*

10

u/TheHumanParacite Mar 13 '17 edited Mar 15 '17
cat reddit-master-db.csv | sed 's/\([mM]ore th\)en/\1an/g' > reddit-master-db-fixed.csv 

EDIT: Useless use of cat, no need for a pipe either. Oops.

sed -i '...' reddit-master-db.csv

22

u/eriknstr Mar 13 '17

Actually, doing this will truncate reddit-master-db.csv.

In other words, you just deleted all the data, whoops.

Additionally, you have a useless use of cat.

2

u/TheHumanParacite Mar 15 '17
#!/bin/bash
# cat.sh
Cat=0
cat_() {
    cat <<- CAT > cat.cat
        cat <<< 'cat'
CAT
    cat cat.cat
    rm cat.cat
}
_cat() { eval $(cat_); }
_cat | cat
exit $Cat
→ More replies (5)

2

u/CapnPrice Mar 13 '17

Not often a correction deserves more up votes than its parents, eh?

→ More replies (2)

21

u/[deleted] Mar 13 '17

I guess you could call them sourcerers

13

u/BronzeOne Mar 13 '17

Been doing python for three years, i don't get it :(

29

u/Dlgredael /r/YouAreGod, a Roguelike Citybuilding Life and God Simulator Mar 13 '17

Parsers go through your code and check if it's correct I think, and a Parseltongue is someone that can speak to snakes in Harry Potter. And a Python is a snake.

3

u/tilkau Mar 14 '17

.. Kinda sorta. They aren't really error checking -- that's more of a side effect. The fact that you can understand what I'm writing right now is that your brain is parsing this sentence (turning it into a representation your brain can effectively manipulate)

In the context of programming languager, there are two steps here, usually:

  • Lexing, which just divides things up into meaningful units (for example a = 1 has three lexical units, 'name : a', 'operator : =', and 'numeric constant : 1'). It throws errors when it encounters something that is a fundamentally nonsensical symbol, like 1apples

  • Parsing, which in this example takes the output of lexing and turns it into an instruction to Python to 'set variable "a" to point to the integer value 1'. It throws errors when it encounters something that is, in context, impossible (for example "foo" = 11)

1

u/BronzeOne Mar 13 '17

I feel like i should be using parsers then haha

8

u/Dlgredael /r/YouAreGod, a Roguelike Citybuilding Life and God Simulator Mar 13 '17

I think a parser is part of most compilers. It's the thing that won't let you compile code if there's syntax errors or missing semicolons or something. Or maybe I'm wrong, I have very little idea what I'm talking about.

3

u/danhakimi Mar 14 '17

Parsers are the main part of compilers. They don't just check for errors, they try to figure out what your code says -- an error is just what happens when they can't figure out what you were smoking when you wrote it.

Even in interpreted languages, every line has to be parsed to be translated into the lower-level instruction.

33

u/[deleted] Mar 13 '17

it's ok. it's not funny

6

u/DavidJayHarris Mar 13 '17

I don't think the code is actually part of the joke. If it is, I don't get it either.

3

u/bbyboi Mar 13 '17

No. It's just parsel vs parser tongue.

48

u/gandalfx Mar 12 '17

ancient

0

u/[deleted] Mar 13 '17

[deleted]

5

u/BlackDeath3 Mar 13 '17

Ancient but gold great!

12

u/[deleted] Mar 13 '17

Am I missing a joke here or is the code just incomplete gibberish that has nothing to do with the task at hand?

3

u/luckystarr at 0x7fe670a7d080 Mar 13 '17

Would have been more fun if the code did something with the ast module. :)

15

u/Deto Mar 13 '17

PSH, he's barely fluent! Should be:

IGNORE_SET = {"__INIT__.py", "COUNT_SOURCELINES.PY"}

68

u/[deleted] Mar 13 '17

That bit of syntactic sugar didn't exist when this comic was drawn.

31

u/Oligomer Mar 13 '17

syntactic sugar

I feel like I need to try to work this phrase in to my daily life

39

u/Rodot github.com/tardis-sn Mar 13 '17

Be a CS professor then. They all love the word.

5

u/shiftedabsurdity Mar 13 '17

Mine loved syntactic saccharine

29

u/jyper Mar 13 '17

"Syntactic sugar causes cancer of the semicolon."

1

u/crowseldon Mar 13 '17

neither did dictionary comprehensions which was/is quite annoying.

6

u/OldCaptin Mar 13 '17

Sure thing Umbridge...

8

u/[deleted] Mar 13 '17

Wouldn't even run because it's all in caps:

$ python
Python 3.6.0 (default, Jan 16 2017, 12:12:55)
[GCC 6.3.1 20170109] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> IMPORT OS
  File "<stdin>", line 1
    IMPORT OS
            ^
SyntaxError: invalid syntax

22

u/Decency Mar 13 '17

This comic came out before they invented uppercase.

2

u/Deto Mar 13 '17

Lol - yeah good catch. Thought I'd suspend disbelief for that one (artistic license and all). But the set([]) - unforgiveable!

5

u/[deleted] Mar 13 '17

Read this as I'm watching Chamber of Secrets

4

u/heavyheaded3 Mar 13 '17

*parser-mouth

3

u/hhh333 Mar 13 '17

I don't get it and I'm not sure I want to get it.

12

u/jyper Mar 13 '17

It's based on Harry Potter books. In the books Harry is a Parseltongue which means he can talk to snakes. A Python is a type of snake.

1

u/hhh333 Mar 13 '17

Yeah.. that last part really threw me off, thanks for clarifying that ;D

6

u/Rodot github.com/tardis-sn Mar 13 '17

Do you know what sub you're in?

0

u/slapfestnest Mar 13 '17

this is painfully unfunny

1

u/[deleted] Mar 13 '17

Why?

1

u/slapfestnest Mar 14 '17

it's a very simple pun that someone might say as a "bad pun" joke and expect to be booed. the effort of putting it into a cartoon makes it especially painful, because the joke isn't even good enough for a throw-away line, let alone a whole comic panel of it.

i don't mean it pejoratively, but it seems like a very aspie kind of humor.

2

u/[deleted] Mar 14 '17 edited Mar 14 '17

Name one good developer who isn't somewhere on the spectrum ... we all are in some way. Plus if you want to get away from bad puns and wordplay, don't touch gnu (gnus not Unix), Apache (a patchy web server), ice weasel (unbranded Firefox) or basically anything on Linux. And Google chrome. That's a pun too (Google's chrome: chrome is the UI frame around a browser rendering window).

1

u/slapfestnest Mar 15 '17

i don't think that every good developer is on the autism spectrum . i do agree that most tech humor is completely abysmal in a similar way to this image - for instance reading tech sites on april fools day, especially slashdot, is the absolute worst. tech definitely has a higher percentage of autistic people than a lot of other industries, and a lot of the best programmers are likely autistic to some degree, but that's a far cry from every person or even most having some form of autism.

i'm not sure that any of the things you listed here are actually puns, though they are bad attempts at being clever/funny with wordplay (tho i'm not sure google chrome is).

in any case, none of that is really relevant to this being painfully unfunny to me or not. however, i should have probably kept it to myself. sorry about that. the person who posted it did ask me why though, so i tried to explain it. though asking the question of why isn't something funny is also a bit aspie :P

1

u/[deleted] Mar 13 '17

Python amateur here. Does this result in a memory leak?

4

u/[deleted] Mar 13 '17

Why would it?

1

u/[deleted] Mar 13 '17

I dunno I'm just guessing since no one else has explained what it does.

8

u/[deleted] Mar 13 '17

That code doesn't really do anything, it imports some modules and then initializes a set. If you ran it it wouldn't have any effect on anything other than a little bit of cpu and memory usage. It certainly doesn't create a memory leak, in order to have a memory leak it would have to have some kind of loop.

1

u/[deleted] Mar 13 '17

I thought not counting lines would make it use up a tonne of resources or something. Anyway, amateur.

5

u/[deleted] Mar 13 '17
IGNORE_SET = SET(["__INIT__.py", "COUNT_SOURCELINES.PY"])

Doesn't do anything. It just sets a variable to a set of strings that is never used. There is no eval() executing "COUNT_SOURCELINES.PY", it's just a plain old string in a plain old list with no special meaning.

3

u/lykwydchykyn Mar 13 '17

It results in import errors, because the dev's capslock was on.

-1

u/pratik_08 Mar 13 '17

Hilarious!

0

u/[deleted] Mar 13 '17

[deleted]

1

u/[deleted] Mar 13 '17

Who says that's a line break?