EDIT: I couldn't use my own modules. It was a stupid waste of time. If you ever have the same problem, try reading this first: http://docs.python-guide.org/en/latest/writing/structure/
I just started OOP with Python and I am confused by modules and classes.
I work with a Mac and I can write my own modules and load them from the site-packages folder.
Now I would like to create modules with useful classes.
import custom_module works.
But if custom_module has a class Custom_class, things don't work.
I tried doing: (EDIT: I am sorry, I am removing old code which was made up, this is what I just used and doesn't work)
in custommodule.py:
class Customclass:
def __init__(self, name):
self.name = name
This module loads without errors. Then I get:
new = custommodule.Customclass('foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Customclass'
BTW, I started trying to do this using code from this tutorial
I was not able to get over this. Please advise, I must be doing something wrong.

custom_module?custommoduleis in the same folder as the file you are working in?dir (custommodule)after you importcustommodule, it should print what you just imported. The code you posted seems good and it work as expected['Customclass', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']which is what I get trying your code