mardi 7 mai 2019

list + map with Python don't return lambda function [on hold]

I'm testint Mediator pattern with python but when I test method with lambda I don't know why return None

def requestPositions(self):
        return list(map(lambda airplane: airplane.position, self.airplanes))

This is all Pattern

class TrafficTower:
    def __init__(self):
        self.airplanes = []

    def requestPositions(self):
        return list(map(lambda airplane: airplane.position, self.airplanes))

class Airplane:
    def __init__(self, position, trafficTower):
        self.position = position
        self.trafficTower = trafficTower
        self.trafficTower.airplanes.append(self)

    def requestPositions(self):
        self.trafficTower.requestPositions()


def main():
    airplane = Airplane(10, TrafficTower())
    #FIX why don't return list
    print(airplane.requestPositions())

if __name__ == "__main__":
    main()

Aucun commentaire:

Enregistrer un commentaire