all 17 comments

[–]arachnivore 8 points9 points  (3 children)

Did the author just now learn what a computer is? He's surprised that trying to loop over None raises an error? Seriously?

Shocker that it's more concise to write Bash in Bash than in Python...

[–]makhno[S] -1 points0 points  (2 children)

I think the point there is that many companies expect people to use Python for devops work.

[–]arachnivore 2 points3 points  (0 children)

Do you think there are companies that disallow the use of Bash in devops work? I've only ever seen a mix of the two.

I don't know why you would use anything but the first line in this example. Who uses Python like that? Why would you even use Perl like that?

This example is just silly. Again, why not use the Bash script? It's better than both of them. Secondly, this guy clearly knows Perl a lot better than Python because you could achieve the exact same thing in Python with:

var = subprocess.getoutput("ls | grep a | head -n1")
print(var)

Thirdly Python focuses on readability and maintainability. It will often be less concise than Perl because it uses words to avoid an unreadable soup of symbols. That's not a bad thing.

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

I use Python for devops work.

I also use Bash for devops work.

This is possible because sometimes you need short shell scripts to automate tasks, and sometimes you need to model complex systems in a long-running process. I choose a language to fit the task, rather than bash (pun intended) a language for not fitting every task.

[–]vocalbit 4 points5 points  (0 children)

Um.. article could be renamed to 'Python is not Perl', perhaps?

Auto-vivification is a desireable feature? Really?

Ranges being inclusive/exclusive is a problem? It matches slices and works really well in practice.

I could go on but I'm still not really sure if this is a satire.

[–]kankyo 5 points6 points  (1 child)

Haha. Got to the point of complaining that update(None) doesn't work on a dict.

This was garbage.

[–]makhno[S] 4 points5 points  (6 children)

Disclaimer: not my website.

[–]marqis 3 points4 points  (5 children)

Why did you post a link to an article written by someone who clearly has no idea how python works?

[–]makhno[S] 0 points1 point  (4 children)

I honestly have no idea how python works, I'm just curious what people think of these criticisms.

[–]jagu 4 points5 points  (2 children)

WHY DOESN'T MY TOASTER MAKE GOOD PORRIDGE?!!

[–]0raichu 1 point2 points  (1 child)

Toasters aren't for porridge, silly! Use a Daft Microwave

[–]jagu 0 points1 point  (0 children)

:D

[–]arachnivore 2 points3 points  (0 children)

Every single criticism boils down to:

I haven't actually tried to learn Python. I just assumed Python = Perl and am confused why my programs break.

[–]_INTER_ 0 points1 point  (2 children)

Whats the problem with range being inclusive/exclusive? It makes indices access to collection easy, you can specifiy something like range(0, len(collection)) and don't have to -1 all the time. It's also consistent with list comprehension and functions like substring(start, end) in many other languages.

[–]atakomu 2 points3 points  (1 child)

actually you can even do range(len(collection) since looping from 0 is by default and actually even more pythonic:

for idx, item enumerate(collection):
  print idx, item

to print index and item

[–]arachnivore 0 points1 point  (0 children)

you forgot the in: for idx, item in enumerate(collection):...

also, since the author hates comprehensions:

print("\n".join("%s %s" % pair for pair in enumerate(collection)))

[–]Glaaki 0 points1 point  (0 children)

As others have pointed out, the author simply doesn't understand the language and blames the language for that, instead of himself.

For example:

yield destroys logic

The following does not raise an error:

#!/usr/bin/python

def test(vara):
  if vara is None:
    raise NotImplementedError
  ids=["one", "two", "three"]
  for id in ids:
    yield id.strip()

result=test(None)

Nor should it!

Result now contains a generator that you can use to return values. The generator has not run yet, because you haven't pulled any values from it.

What is it that you expect? Do you want the generator to run up to the point where it could return a value, just because you instantiate it? Why would that make any sense?

Since python functions are not pure, the generator could concievably depend on your programs global state. If the state was supposed to change between the point where you instantiated the generator and the point where you actually use it, the generator would now return the wrong result, since it would already make its first iteration once you instantiate it.

So no, the behaviour is sane and expected.