Python - how to reference one object to another
class, python
Solution
Try:
class Person(object):
def __init__(self, fn, ln, address):
self.uid = Id_Class.new_id("Person")
self.f_name = fn
self.l_name = ln
self.address = address
class Address(object):
def __init__(self, st, sub):
self.uid = Id_Class.new_id("Address")
self.street = st
self.suburb = sub
hm = Address('Queen St.', 'Sydney')
s = Person('John', 'Doe', hm)
Problem
more basic questions i'm struggling with... Give the basic code below... how does the person object get the address "attached" to it. ``` class Person(object): def __init__(self, fn, ln): self.uid = Id_Class.new_id("Person") self.f_name = fn self.l_name = ln class Address(object): def __init__(self, st, sub): self.uid = Id_Class.new_id("Address") self.street = st self.suburb = sub s = Person('John', 'Doe') hm = Address('Queen St.', 'Sydney') ```