Changes between Initial Version and Version 1 of Ticket #8596, comment 4
- Timestamp:
- Feb 4, 2019, 3:12:44 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #8596, comment 4
initial v1 1 This error statement [http://net-informations.com/python/iq/typeerror.htm TypeError:] 'module' object is not callable is raised as you are being confused about the Class name and Module name. The problem is in the import line . You are importing a module, not a class. This happend because the module name and class name have the same name .1 This error statement `TypeError: 'module' object is not callable` is raised as you are being confused about the Class name and Module name. The problem is in the import line . You are importing a module, not a class. This happennd because the module name and class name have the same name . 2 2 3 If you have a class "MyClass" in a file called "MyClass.py", then you should import :3 If you have a class `MyClass` in a file called `MyClass.py`, then you should import : 4 4 5 5 … … 9 9 10 10 11 In Python , a script is a module, whose name is determined by the filename . So when you start out your file MyClass.py with import MyClassyou are creating a loop in the module structure....example11 In Python , a script is a module, whose name is determined by the filename . So when you start out your file `MyClass.py` with `import MyClass` you are creating a loop in the module structure....example 12 12 13 13 In Python, everything (including functions, methods, modules, classes etc.) is an object , and methods are just attributes like every others. So,there's no separate namespaces for methods. So when you set an instance attribute, it shadows the class attribute by the same name. The obvious solution is to give attributes different names.