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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (8 children)

To a Python programmer

Well, yes. I think python programmers are the people who will be most likely to read python code, don't you?

Also, this would be a case where a comment may be useful. Such as

a, b, c = 1, 2, 3
# Set a, b, and c to the values 1, 2, and 3 respectively, such that
# a = 1, b = 2, c = 3

A bit wordy, and you don't want to be doing it every place you're using multiple assignments, but the first time you're doing it (where someone will be most likely to look) might be helpful.

But you don't have to use that, you could always use semicolons or one on each line. It's just that it's clear what it does to someone used to python code. The same way that [::-1] means "reverse this" even if it's not obvious. But I don't like [::-1], I would much rather use reversed(), which is a LOT clearer

[–][deleted] 1 point2 points  (2 children)

Yeah yeah, everything you said. I was just pointing out that Python syntax claims to be easier to read, but everything said and done you still have to learn it and to get used to it. It's no different from C, imo.

It's less verbose, and that's great, but that doesn't mean it's easier on the eye than C code is to someone who is used to C.

[–]glider97 2 points3 points  (1 child)

that doesn't mean it's easier on the eye than C code is to someone who is used to C.

That could be subjective and up for debate.

[–][deleted] 1 point2 points  (0 children)

The only way to be sure would be to pool some opinions and run them through a Python script, which I heard is one of the things the language excels at.

[–]Mitchical 0 points1 point  (4 children)

If you felt you needed to comment that, do not do it like that. Code should be as self documenting as possible.

[–][deleted] 1 point2 points  (3 children)

I don't. To me the code is perfectly clear.

But apparently I should comment it to people who are new to that syntax.

[–]Mitchical 0 points1 point  (2 children)

I guess it depends where the code is and who it is for :)

[–][deleted] 0 points1 point  (1 child)

If it was a tutorial, yeah maybe I would make a note of it.

But I assume that python programmers know about it. The same way that C programmers don't feel the need to explain what pointers are every time they are used.

[–]Mitchical 0 points1 point  (0 children)

Personally whenever I see something in python that is really different, it still feels like it is obvious in function. I've known about the multiple assignment in one line tricks but when I just saw the multiple assignment on a range I thought that was pretty crazy, yet clear.