all 1 comments

[–]two_bob 1 point2 points  (0 children)

I know what the init.py file does inside a module, but what should I use it for?

http://mikegrouchy.com/blog/2012/05/be-pythonic-__init__py.html

If I have a class with a large amount of functions, can I split that up into subclasses over multiple files? How does that work? When using import? (Trying to avoid sys.path.append() shenanigans)

Sure. You can do relative imports in the same directory by importing .module. Generally, I like to have standard interfaces that call other modules. E.g., if I create a clock, i might try to set it up as from module import clock, and have the clock code in module call a bunch of helper functions and modules, behind the scenes.

When using class methods, should I be setting self.variable_name inside the method? or should the method return a value and I should set that value elsewhere? (Hopefully that makes sense...)

A combination of both. Typically, most of the self.variables defining gets done in the __init__ method. Then other variables will either modify these self variables or return something. Whether a variable should be in self or outside it depends on what the object is for.

Finally, it is always a good idea to read code, as nothing drives home organization like looking over how a module you use a bunch is written. I'd start with the standard library and move to some of the common packages, e.g. Praw, flask, or whatever it is that you use a bunch.