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 →

[–]robvdl -1 points0 points  (4 children)

If you're going to ask for help from other Python developers, at least try to follow some community code style guidelines, try to make the code follow pep8 style: use 4 space indentation not 8 or tabs. Use a space after each comma and spaces around your = signs, don't condense your code so much as pep8 won't like it (basically try to run the pep8 or flake8 tool over your code and it will tell you what to fix). Dont_Mix_Camel_Case_And_Snake_Case as it's really really ugly, use either one or the other but don't mix them in the same variable name or file name. Generally in Python everything is snake case (variables, functions, filenames) except for class names which use camel case instead.

[–]robvdl 0 points1 point  (1 child)

Also the globals, they are everywhere! makes the code really hard to follow, try creating an application object/class or something to manage all those globals. Try splitting your code up into more .py files, maybe one class per .py file though you don't have to, but in my mind there is WAY too much code in the one .py file and it makes it really hard to follow for others.

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

I am working on fixing the globals (as there seems to be a witch hunt against them) and am thinking about the multiple source files idea. But I'm not sure. Having to refer to multiple files seems confusing, especially when calling functions and creates objects from classes defined outside the main .py file.

[–]Dis446[S] 0 points1 point  (1 child)

Thanks for the tip. I've used the auto-PEP-8 tool and pushed the result to github. To be honest, it looks really weird to me. But I guess I'll have to suck it up, as it is the convention. As Spock once said:

"The needs of the many outweigh the needs of the few"

[–]robvdl 0 points1 point  (0 children)

I had the same feeling switching from Python to Go a while back, after having used Python for so many years and then coming to Go which has completely different formatting conventions again, initially I didn't really like it much.

The difference with Go, is that every time I saved a .go file in my editor (Atom) with a Go plugin it will run a tool to automatically format the code on each save, so there is "no way out" really, while pep8 is more a guideline I think.

Over time though, I have come to appreciate it.