0

I'm trying to pass an instance of the class to member function of the same class like:

class LatLong():
    def __init__(self, lat, long):
        self.lat = float(lat)
        self.long = float(long)
    def distance_to(self, latLong: LatLong):
        pass

I get Class is not defined error:

<ipython-input-5-139f9b0f07a2> in LatLong()
      3         self.lat = float(lat)
      4         self.long = float(long)
----> 5     def distance_to(self, latLong: LatLong):
      6         pass

NameError: name 'LatLong' is not defined

How do I apply a type constraint if that's not possible?

Saravanabalagi Ramachandran
  • 8,551
  • 11
  • 53
  • 102

0 Answers0