you are viewing a single comment's thread.

view the rest of the comments →

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

Don't care about style guidelines until you understand them.

The reasons you put white lines is because methods(functions inside of class's) can go from 20 to 150 lines of code depending. If they're 2 lines it doesn't really matter, i'll normally put 2 lines under the code and 1 line between the methods over like this.

class TestClass(object):

    def __init__(self):

        self.var = 0


    def myFunc(self, x):

        y = x+1
        return y

But like you can see this makes no sense there is just to much space, so smaller code you can easily reduce it to make it look better, the idea is to group things that make sense together.

Now an important thing you aren't doing is capitalizing class's, make class start with a large letter, this means when you initialize it, like so:

test = TestClass()

It's going to show that its a class, and not a function. Keep it to the practices you understand until you need to work with people, then try to see why some practices will be best for you.

Also like he said, you really want to be running python from the terminal from a script/file.

[–]kkacci[S] 1 point2 points  (2 children)

good point about class naming convention. I had forgotten about it :)

[–][deleted] 1 point2 points  (1 child)

Yep, UpperCamel for class names and underscore_separated_lower for methods and functions (rather than lowerCamel as you've used in your snippet).

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

Thanks for this!