I'm fairly new to python and currently struggling to do the simple thing of importing a file from an outside directory.
Let's consider two files :
// src/class/Rider ....
class Rider(object) :
def __init__(self, firstname, lastname, emailaddress, phonenumber, pickuplocation, dropofflocation, pickuptime, dropofftime):
self.FirstName = firstname
self.LastName = lastname
self.EmailAddress = emailaddress
self.PhoneNumber = phonenumber
self.PickUpLocation = pickuplocation
self.DropOffLocation = dropofflocation
self.PickUpTime = pickuptime
self.DropOffTime = dropofftime
def set_rider_name(self):
first = self.FirstName
last = self.LastName
return first + last
and
//src/method/rider
# importing Rider class in here ...
I'm struggling to import the Rider
class from src/class/Rider
into the src/method/rider
file so I can actually use that class.
Coming from node.js and being used to the import/export
of es6
, I'm still learning python 2.7
.
my root directory is something like : ../Golf-cart/src
, where I have class
and method
subdirectories inside src/
How can I import my class definition into my method file so I can actually use it there ?