I'm very much new to Python, essentially being pushed into a new project with no knowledge of the language whatsoever. I've gone over a number of tutorials to get a gist of the syntax and some of the functions, but I'm currently stumped on something that seems pretty basic.
I have a class GeoLocationHandlerObj in GeoLocationSolver.py which has a method 'myMethod':
class GeoLocationHandlerObj(object):
def __init__(self, connector, debug=0):
self._debug = debug
self.locator = GeoLocationSolverObj(connector)
return(None)
def close(self):
...
return(None)
def getAdr(self, point, lang):
...
return(None)
def getCom(self, point, lang):
...
return(None)
def getHmp(self, point, lang):
...
return(None)
def myMethod(self):
print "test"
return(None)
I import it and try to call myFunction:
import sys
import os
import psycopg2
import string
import json
import socket
import random
from GeoPackage.GeoCoding.GeoLocationSolver import *
if __name__ == "__main__":
connector = GeoPSConnectorObj(...)
handler = GeoLocationHandlerObj(connector)
handler.myMethod()
When I run this code, I get the following error:
AttributeError: 'GeoLocationHandlerObj' object has no attribute 'myMethod'.
What am I missing in order to successfully call this method?
print(dir(handler))?import *clutters the namespace and you don't necessarily know with what. With my suggestion, you would then reference the class withconnector = gls.GeoPSConnectorObj(...)then you're explicit which module that class comes from.import GeoPackage.GeoCoding.GeoLocationSolver as gls,print(gls.__file__)is the path correct?