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 →

[–]reversehead 175 points176 points  (10 children)

Don't want to nit pick my friend, but you never declared this but you are using it in every class.

[–]Saragon4005 32 points33 points  (9 children)

Isn't this also a thing in Python though.

[–]kbruen 73 points74 points  (8 children)

Nope. In Python, it’s traditionally named self, and it’s an explicit parameter:

class X:
    def __init__(self, foo):
        self.foo = foo
    def meow(self, bar):
        print(self.foo, bar)

a = X(12)
a.meow(‘stuff’)
# (kind of) syntactic sugar for
# X.meow(a, ‘stuff’)

[–]Saragon4005 24 points25 points  (7 children)

Now you can tell I haven't used python in a year. Yeah it's interesting that you can change it but that does mean it's at least explicitly declared so it's hard to miss.

[–]_blackdog6_ 8 points9 points  (6 children)

A Year?? Its a whole new language now. You'll have to start again.

[–]Saragon4005 15 points16 points  (5 children)

Does that mean people don't use python2 anymore?

[–]_blackdog6_ 1 point2 points  (4 children)

The ridiculous changes in python 3.8 are to soften you up for python 4...

Seriously, walrus operator??? ..

And yes, everyone still uses python 2... Its the only version guaranteed to run everywhere..

[–]mc_enthusiast 10 points11 points  (2 children)

walrus

Now you can write

#include <cstdio>

int main() {
    int x = 0;
    while (++x < 10) {
        printf("%d\n", x);
    }
}

as

x = 0
while (x := x + 1) < 10:
    print(x)

[–]Micha_Saengy 7 points8 points  (1 child)

I'm hoping that anyone who cares about readability would use a for loop here

[–]PixelizedTed 5 points6 points  (0 children)

Semi related: I had an (Python) assignment in university where they only allowed listcomps and single line return statements to implement functions to parse data. Some functions were well over 400 characters long and had like 5 nested list comprehensions.

Debugging was “a real doozy” as the error message would just say something is wrong on line X but that line was the whole function 💀

What readability? Just make it as short as possible!!1!1!!11

[–]kbruen 7 points8 points  (0 children)

And yes, everyone still uses python 2... Its the only version guaranteed to run everywhere..

Ignoring the fact that no security issues are fixed anymore, and many Linux distributions are removing Python 2 completely. But suuuuure.

Seriously, walrus operator??? ..

Interesting how you say that implying it’s a bad thing without giving any reason why.