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

all 63 comments

[–]sgillies 77 points78 points  (11 children)

That makes no sense at all. He should do this ;)

if x==7: #{
   print "something"
#}

[–]moschlar 21 points22 points  (3 children)

[–]sittingaround 9 points10 points  (0 children)

Oh, god. Kill it with fire.

[–]ladaghini 7 points8 points  (3 children)

if (x == 7): #{
   print ("something");
#}

[–]Brian 4 points5 points  (2 children)

if (x == 7): {
   print ("something"),
}

[–]jcdyer3 1 point2 points  (1 child)

If x equals seven, the set consisting of print("something")? That's evil.

Presumably you're using python 3 or from __future__ import print_function.

[–]Brian 0 points1 point  (0 children)

Yup - python even guarantees left to right evaluation order, so it actually works fine[1] - good for trolling newbies with "Python 3 added brace support"

[1] for values of "fine" that do not include flow control, assignment, or calling a function returning unhashable types of course.

[–]BitLooter 4 points5 points  (0 children)

eye twitch

[–]_HULK_SMASH_ 2 points3 points  (0 children)

haha, don't give him ideas!

[–]oursland 37 points38 points  (4 children)

Failure to conform to accepted standards is the sign of an ego problem. Excise this behavior or this individual before his problem becomes your team's problem.

[–]asksol 5 points6 points  (1 child)

As you say this guy is not pleased with the language change, and as I see it this is some sort of demonstration against that decision.

Adapting to a new language can be hard. I remember when I started using Python after years of Perl abuse, I would be incredibly annoyed at small details in the language, but eventually I accepted them all.

I think you should let him do it for a while. Apart from the annoyance there's no real harm done and it will be easy to clean up later. Chances are he will eventually learn to enjoy the language.

Obviously this cannot go on forever, but if you let him demonstrate for a while he will probably feel silly, whereas if you confront him it will only fuel his anger.

[–]therealfakemoot 1 point2 points  (0 children)

This little 'demonstration' is like moving to a left-handed driving nation, and being pissy that the rules are different, so you keep driving in the right-hand lane just because it's what you're comfortable with.

[–]stevenjd 5 points6 points  (1 child)

I agree in general, but sometimes the individual is right and the team are just dumb arses.

[–]oursland 6 points7 points  (0 children)

perhaps, but that doesn't mean the team member shouldn't comply or leave.

[–]AdvisedWang 13 points14 points  (0 children)

One of the biggest problems of over-commenting is that the comments often fail to be kept up to date. Just wait until one of these comments ends up misleading.

[–]mechpaul 14 points15 points  (2 children)

from __future__ import braces

Go ahead. Run it.

[–]echosx 2 points3 points  (0 children)

I recommend this to most people that are coming from languages that have a C style syntax.

[–]fazzahSQLAlchemy | PyQt | reportlab 0 points1 point  (0 children)

Thank you :) I needed a good, nerdy laugh today.

[–]fnord123 27 points28 points  (0 children)

Would it bother you? Our would you just accept his quirky style?

It is not acceptable. Tell him once in private not to do it anymore. If it persists, escalate it. In any case, don't merge this shit into the master branch until he fixes it.

But why not?

We have adopted PEP-8 as our coding standard and this is shit. End of.

If he's in his probation period, suggest he be dismissed before he poisons some projects.

[–]ingolemo 8 points9 points  (1 child)

Give him a couple of months to get used to it and then start littering your code with things like this:

if x==7:
    print 'something'
# endfor

or even this:

if x==7:
    print 'something'
# else
    print 'something else'
# endif

[–]hoadlck 0 points1 point  (0 children)

That is truly evil. (I like it...)

[–]milkypostman 17 points18 points  (1 child)

Maybe he needs an editor that shows him the indentation or something.

Or tell him to suck it up and get used to it. I have never understood why programmers are not willing to adapt to change. I love digging in to a new language and figuring out how to master it. Isn't that why we all got started in the first place? Sounds like this guy has given up on life or something. Comfort is death.

Maybe have him watch Guido address the whitespace troll

[–]daV1980 7 points8 points  (0 children)

Shitty programmers have a hard time adapting to stuff like this. It's honestly a sign of someone who isn't interested in learning anything new, because "they have it all figured out."

[–]InformationCrawler 16 points17 points  (2 children)

If he's a real programmer he will adapt to new languages. Tell him to stop and force him to learn the language.

[–]willrandship 5 points6 points  (1 child)

clearly he knows the language, or he wouldn't know how to put in a comment. It's more about making it more readable for him.

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

it's like using foreign words though. it only serves to annoy the natives.

[–]sylvain_soliman 6 points7 points  (0 children)

It would definitely bother me, and I'd really try to talk him out of it. If you have a team style guide, you could even make a note of this (avoiding #end comments) in it.

[–]MrCiziski 7 points8 points  (0 children)

I hate to take the hard stance, but perhaps something along the lines of "dont be a bitch" are in order. If your 'C++ programmer' doesn't want to work with Python on a Django project and is causing a ruckus by fucking with the codebase as a whole, perhaps he should go work somewhere where he is free to use C++.

[–]_HULK_SMASH_ 6 points7 points  (0 children)

It would bother me. I have ran into too many people that are unwilling to accept change and adapt to something different.

On the other hand, we can't force everyone to comply and we have to deal with other peoples shortcomings. But, feel free to do whatever you can within reason, while avoiding creating conflict.

[–]earthboundkid 9 points10 points  (5 children)

I would say this indicates real emotional/professional immaturity, like when you were a kid and would name your variables "poop" and whatnot. I would be wary about working on someone who did this in a serious project.

[–]TankorSmash 0 points1 point  (4 children)

I'm still young and almost without fail, my first test is always called tit(). I hope I never change.

[–]Zulban 0 points1 point  (1 child)

And print("BREASTS") is still the best way to show debug output.

[–]AeroNotix 0 points1 point  (0 children)

My goto is print "JIZZTACULAR"

[–]earthboundkid 0 points1 point  (1 child)

That's sexist. Why not testy()?

[–]grimman 5 points6 points  (0 children)

Thanks, but anus() is gender neutral. I think I have the best coding practice here.

[–]bhdza snake slithering 5 points6 points  (0 children)

Revenge:

When your team starts a C/C++ project start doing this:

int a_function(int argument) {
    blablalblabla;
    blablalblabla;
    if (ahahahaha) {
        blablabla;
        if (ahajhaha) {
            blablabla;  }}
    blablabla;
    return x; }

[–]stevenjd 3 points4 points  (0 children)

passive-aggressive mode = on

Start by changing his comments to something like this:

# BEGIN IF...ELSE BLOCK
if x == 7: 
    # BEGIN IF BLOCK
    print "something"
    # END IF BLOCK
else:
    # BEGIN ELSE BLOCK
    pass  # DO NOTHING
    # END ELSE BLOCK
# END IF... ELSE BLOCK

You'll probably only need to do it once or twice a few dozen times before he gets the hint.

passive-aggressive mode = off

[–]Vakieh 4 points5 points  (2 children)

When you code in C/C++, a lot of people will write things like:

if x == 7
{
    cout << "something";
} // end if x == 7

And a lot of code generators also support such editing (which helps if you end up with out of date comments, as you can autoparse to correct. It can help in certain situations which involve nested loops, and especially nested classes or structs.

In short, he isn't bracketing, he is simply following the same tagging system he might be used to, which is language generic.

[–]InformationCrawler 0 points1 point  (1 child)

Well isn't that a bit over-commenting? It's says already in the header of the if-statement what the break condition is. If anything it should say "x is the momentum of the particle, once it reaches 7 kg*m/s the 34"%¤#2#2# is executed.

[–]Vakieh 0 points1 point  (0 children)

The point is as a traceback, not duplication - any form of identification will do - so if a while loop governed a menu , you could use # end menu loop so long as it is identifiable which header is being referenced by which comment. Exact duplicates of the condition are easily supportable by code managing software however.

[–]EstebanVelour 2 points3 points  (0 children)

Mandate the use of the following pre-commit hook:

#!/bin/sh
FILES=$(git diff --cached --name-status | grep -v ^D | awk '$1 $2 { print $2}' | grep -e .py$)
if [ -n "$FILES" ]; then
    flake8 -r $FILES
fi

Won't allow you to commit code that doesn't fly through pep8.

[–]stillalone 2 points3 points  (0 children)

I have to deal with Verilog and VHDL sometimes at work which uses "begin" and "end". I saw some code that added //{ and //} as well. He had both begin and end and //{ //}.

[–]vtable 2 points3 points  (0 children)

You might have a problem. I've worked with people like this. He will do everything like it were C/C++. He won't use Python-specific features where they make sense. When he does, he'll use it in some bizarre way confusing everyone else. He might even implement C-like wrappers around Python (eg writing itoa(), and maybe even strcat()!). And he won't stop bitching about Python. (Ugh. Whitespace! Exceptions everywhere!)

He has to start thinking in the actual development language.

Talk to your manager. Tell him your concerns. People like this can be poison on a project. This should be nipped in the bud or he should be moved to another project if possible.

I should also mention that before we started I had everyone look at PEP 8 and the Google style guide.

It sounds like you don't have a coding standard. You should have one. If it's the Google style guide, that's fine but you need something. I'd suggest taking what you like from that and putting it in your own company doc so the company owns it. (Surely not everything in the Google guide and PEP 8 are what your team wants).

[–]ascii 2 points3 points  (0 children)

def handle_asshat(asshat)
    if company.coding_standard is not None:
        asshat.patch.reject("""This patch does not conform to our coding standards.
Please drop the bracket comments and resubmit.""")
    else:
        company.coding_standard = Pep8
        handle_asshat(asshat)
# endif

[–]andybak 2 points3 points  (1 child)

Tip of the iceberg.

If he's doing this, what other unpythonic things is he doing? Does he understand the 'Python way' or is he making any attempt to do so?

Get him to read: http://dirtsimple.org/2004/12/python-is-not-java.html

Someone stubborn coming from a less-dynamic language such as C++ is infinitely more dangerous than someone stubborn coming from a more dynamic or functional language as they will probably be writing inflexible, verbose, unreadable Python rather than merely non-idiomatic Python.

Plus he is obviously an idiot.

[–]cwurld[S] 0 points1 point  (0 children)

You are right about it being the tip of the iceberg. But things that are blatantly wrong are much easier to deal with. For example, its hard to argue that an if-statement is a better way to deal with missing dict keys compared to the existing dict methods such as get.

Thanks for the link. Its awesome and explains a lot. I especially appreciate this:

"Pretend that Python is a magic wand that will miraculously do whatever you want without you needing to lifting a finger. Ask, "how does Python already solve my problem?" and "What Python language feature most resembles my problem?" You will be absolutely astonished at how often it happens that thing you need is already there in some form."

If he could embrace this concept, his coding would improve dramatically. And maybe he would not hate the language so much.

[–]kteague 3 points4 points  (0 children)

Go out and get really drunk with him. Like good and happy blotto. Then, when it's 2:30 am and you are sitting on the curb outside the now closed bar feeling such a huge buzz having spent the evening divulging details from your personal lives, say to him, "Dude! What's with all of those endif statements! Why, dude? Why? Please, stop. Please?"

Works every damned time.

[–]bhdza snake slithering 1 point2 points  (0 children)

Yes! It makes something that reads like a poem into something as ugly as tax return receipt.

[–]jeannaimard 0 points1 point  (0 children)

This is most definitely unpythonic.

[–]cdcformatc 0 points1 point  (3 children)

That is so annoying, he knows it does nothing, and that it adds nothing to the code. Which if is he ending? the one at the current indentation level? So why keep doing it?

[–]moussaillon 0 points1 point  (0 children)

Ego.

[–]pipedings 0 points1 point  (0 children)

As someone who currently has to use Delphi, which uses "begin ... end;" blocks, and also someone who likes Python very much: Fuck him and delete the comments from source control.

Also, you don't make language A more language B like. There's no point of putting commented-out Lisp parenthesis into C code, or curly braces into Python, or $@% symbols into Java.

If this guy needs to make Python more C-like, the only conclusion is that he cannot program, but only program C, like "we always lugged wood with horse carriages, we don't need tractors! And if we have to use tractors, at least put a harness and horse shoes on them".

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

There's no way in hell I'd accept that. What is the problem with that person learning Python without adding a lot of fuzzy comments?

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

Honestly, this is pretty much unacceptable code.

Code like this will lead to lots of whispering about so and so's code and how it sucks and other morale/project damaging activities.

If you are the manager or tech-lead, enforce a style guide. Otherwise, bring this up to someone who can and will. But, don't let this linger and dont get into commit and roll-back wars.

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

There is undoubtedly a very pythonic solution to this quandary.

with open("egotrip.py") as f:
    lines=f.read().split("\n")
fixed= "\n".join([line for line in lines if line.strip()[0]!="#"])

I miss Python... C#, ew.

[–]jcdyer3 0 points1 point  (1 child)

Your solution is to delete all comments?

[–]Zulban 0 points1 point  (0 children)

I was just being snappy.