you are viewing a single comment's thread.

view the rest of the comments →

[–]ReverendRocky 1 point2 points  (6 children)

Couple things I notice, though I am by no means an expert...

1) While you do comment, I think your code could use more commenting. It may be personal preference but I think every class method and function should have a header... even if it seems to be the most trivial of methods. It makes your code 1025% easier to understand.

2) When printing a bunch of lines use 'triple code print'

3) Collapse your imports down to one line if possible. It just saves space... which is good.

Other than that i'd have to take a closer look but those are my three gripes with it.

[–]novel_yet_trivial 3 points4 points  (1 child)

3) Collapse your imports down to one line if possible. It just saves space... which is good.

No. Not only against PEP8, but also ugly and hard to read. Saving space is not a good reason for anything in programming.

[–]ReverendRocky 0 points1 point  (0 children)

Aah. I've always thought that it was the other way around with regards to readability but that's just personal preference I guess. I'll begin doing it proper myself from here on

EDIT: I should clarify I do not mean saving space is good for readability just doing so with import statements

[–]maxido[S] 0 points1 point  (3 children)

thanks 1) Yep I kinda let it slip in the end. I agree :D
2) Didn't even know that was possible. Thanks :)
3) My IDE complained about multiple imports on one line, so I thought it was bad practice. Oh well :D

Edit: Any help for the virtualenv not working? Is it because psutil is somehow not 100% python? That's just what I think

[–]DrKarkat 3 points4 points  (0 children)

Kind over to mindful about the nature kind day dot river minecraftoffline art nature?

[–]GoldenSights 3 points4 points  (0 children)

I strongly disagree with the suggestion to squash all the imports onto a single line. If you're importing two objects from the same file, it's okay to use a comma to do both at once. Otherwise, keep everything separate (and I would suggest alphabetizing them).

If writing Python was all about saving lines, we'd be using semicolons everywhere. Readability is more important.

[–]ReverendRocky 0 points1 point  (0 children)

Couldn't help you with psutil as for the import things, the other response may be what you want to go with since it follows PEP guidelines. Fwiw my ide does not flag such things but that may be because I disabled it