Python calling other python function error?

Viewed 54

I am trying to call the python function elevation2 (the file is called elevation2.py and the function def elevation2) in the same folder as my current file.

     import numpy as np         
     import elevation2
     def callgoogle(latmin,latmax,samples1, lngmin,lngmax,samples2):
      elev=[]
    if samples1 <= samples2:
        i = 0
        while i<samples1: 
            i = i+1
            w = latmin + i*(latmax-latmin)/samples1 
            if i == 1:
                elev = elevation2(w, lngmin,w,lngmax,samples2)
            else:
                elevo = elevation2(w, lngmin,w,lngmax,samples2)
                elev = np.c_[elev, elevo]                 
    else :
        i=0
        while i<samples2:
            i = i+1
            w = lngmin + i*(lngmax-lngmin)/samples2 
            if i == 1:
                elev = elevation2(latmin, w,latmax,w,samples1)
            else:
                elevo = elevation2(w, lngmin,w,lngmax,samples2)
                elev = np.c_[elev, elevo]     
    return elev

and the error I get is

TypeError: 'module' object is not callable

I wonder what that means?

The code in the elevation2 file is

import json as simplejson
import json
import urllib
import ssl


 ssl._create_default_https_context = ssl._create_unverified_context


def elevation2(lat1, lng1,lat2,lng2,samples):
2 Answers

elevation2 file

class Elevation2:
   ........ your code
   def yourMethod():

end elevation1 file

from Elevation2 import elevation2 

e=Elevation2()
e.yourMethod()

try this

Now that you've added your elevation2 code, the question is possible to answer.

The issue is that elevation2 is a function within the elevation2 module.

Therefore, try calling elevation2.elevation2(...) instead of elevation2(...).

Related