Python 3.4 - 'module' has no attribute 'send_sms'
Question: For some reason I cannot execute the function of another script even though i
imported that module.

The relevant code for 'master_module.py' goes like this:

    
    
    import sms_values
    
    class ClientThread(threading.Thread):  # Class that implements the client threads in this server
        def __init__(self, client_sock):  # Initialize the object, save the socket that this thread will use.
            threading.Thread.__init__(self)
            self.client = client_sock
    
        def run(self):  # Thread's main loop. Once this function returns, the thread is finished and dies.
            global QUIT  # Need to declare QUIT as global, since the method can change it
    
            done = False
            cmd = self.readline()  # Read data from the socket and process it
            while not done:
                if 'quit' == cmd:
                    self.writeline('Ok, bye. Server shut down')
                    QUIT = True
                    done = True
                elif 'bye' == cmd:
                    self.writeline('Ok, bye. Thread closed')
                    done = True
                elif 'send' == cmd:
                    sms_values.send_sms()
                    self.writeline('text should be sent')
                    done = True
                else:
                    self.writeline(self.name)
                    cmd = self.readline()
    
            self.client.close()  # Make sure socket is closed when we're done with it
            return
    

Notes:  
The entire code is omitted for clarfication of where the error is  
There is no `__name__ == '__main__'` block in `sms_values.py.`  
`send_sms()` is not defined inside a class  
No indentation on define line, so it's module-level.

Here I'm trying to execute a function from another module in a threaded
continuously run server with the conditional 'send' written in user console.

And this is the code i'm running contained in sms_values.py:

    
    
    def send_sms():
        try:
            ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            port = 80
            ss.connect((127.0.0.1, port))
            a = url.encode('ascii')  # string needed to change into bytecode
            print(sys.stderr, 'sending "%s"' % a)
            ss.sendall(a)
    
            amount_recieved = 0 
            amount_recieved = len(a)
            while amount_recieved < amount_expected:
                data = ss.recv(180)
                amount_recieved += len(data)
                print(sys.stderr, 'closing socket')
                ss.close() 
    

Note: The entire code is omitted for clarfication of what function i'm
calling.

Fairly straight forward, I just want to send a http POST / GET command to a
router when someone types send in the continuous run server. However traceback
flags up this:

    
    
    Exception in thread Thread-1:
    Traceback (most recent call last):
      File "C:\Python34\lib\threading.py, line 920, in_bootstrap_inner
        self.run()
      File "C:\Users\Savag\PycharmProjects\master_module.py", in line 29, in run
        sms_values.send_sms()
    AttributeError: 'module object has no attribute 'send_sms'
    

Can anyone please shine some light on this?  
I sort of suspect it's because i'm working within a class on another module?
I'm not sure if that even matters. Other module/attributeerror answers have
either not been answered or don't help this situation.  
Now I have imported the other module, `from sub_module import sms_values` also
doesn't work for me.


Answer: So yet again i've answered my own question. All that needed to happen was that
the module needed to be stored to a value. Adding:

`z = sms_values`

then `z.sendsms()` in the `elif 'send' = cmd:` loop, worked.

