Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Calling Class Error: The Sequel

$
0
0
Wasn't sure if to continue with the old thread since it's vaguely similar in terms of what the problem is; unlike my last problem where I had multiple classes within a single file, I've had to split my code into a few separate files for sake of brevity/debugging/etc.

Anyhow... once I execute say a particular file that imports from another and try to call a few methods from that class, I get something like this:
##running Loader.py

>>> x = vectors()
>>> x.load_Pos()

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    x.load_Pos()
  File "C:\Python\workbench\2d_astro\Loader.py", line 25, in load_Pos
    Operator().set_posX(pos_x)
TypeError: 'module' object is not callable



The code looks something like this:
#Loader.py
import Operator

class vectors(object):
    def load_Pos(self, pos_x = 0, pos_y = 0, pos_z = 0):
        Operator().set_posX(pos_x)
        Operator().set_posY(pos_y)
        Operator().set_posZ(pos_z)

        vector = [Operator().get_posX(),
                  Operator().get_posY(),
                  Operator().get_posZ()]
        
        return vector


Which is calling from this:
#Operator.py
import math

class functions(object):

    def set_posX(self, pos = 0):
        self.pos_x = pos

    def get_posX(self):
        return self.pos_x



I'm would be almost certain that I'm not typing out the proper syntactical form for calling other classes (in other files) or something, but I can't figure out exactly how python wants it to be as "input".

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>