I am trying to rephrase the implementation found [here](https://machinelearningmastery.com/tutorial-to-implement-k-nearest-neighbors-in-python-from-scratch/). This is what I have so far:

```
import csv
import math
import random

training_set_ratio = 0.67

training_set = []
test_set = []

class IrisFlower:
    def __init__(self, petal_length, petal_width, sepal_length, sepal_width, flower_type):
        self.petal_length = petal_length
        self.petal_width = petal_width
        self.sepal_length = sepal_length
        self.sepal_width = sepal_width
        self.flower_type = flower_type

    def __hash__(self) -> int:
        return hash((self.petal_length, self.petal_width, self.sepal_length, self.sepal_width))

    def __eq__(self, other):
        return (self.petal_length, self.petal_width, self.sepal_length, self.sepal_width) \
               == (other.petal_length, other.petal_width, other.sepal_length, other.sepal_width)

def load_data():
    with open('dataset.csv') as csvfile:
        rows = csv.reader(csvfile, delimiter=',')
        for row in rows:
            iris_flower = IrisFlower(float(row[0]), float(row[1]), float(row[2]), float(row[3]), row[4])
            if random.random() < training_set_ratio:
                training_set.append(iris_flower)
            else:
                test_set.append(iris_flower)

def euclidean_distance(flower_one: IrisFlower, flower_two: IrisFlower):
    distance = 0.0
    distance = distance + math.pow(flower_one.petal_length - flower_two.petal_length, 2)
    distance = distance + math.pow(flower_one.petal_width - flower_two.petal_width, 2)
    distance = distance + math.pow(flower_one.sepal_length - flower_two.sepal_length, 2)
    distance = distance + math.pow(flower_one.sepal_width - flower_two.sepal_width, 2)
    return distance

def get_neighbors(test_flower: IrisFlower):
    distances = []
    for training_flower in training_set:
        dist = euclidean_distance(test_flower, training_flower)
        d = dict()
        d[training_flower] = dist
        print(d)
    return

load_data()
get_neighbors(test_set[0])

```

Currently, print statements in the following code block:

```
def get_neighbors(test_flower: IrisFlower):
    distances = []
    for training_flower in training_set:
        dist = euclidean_distance(test_flower, training_flower)
        d = dict()
        d[training_flower] = dist
        print(d)
    return

```

will have outputs similar to

```
{<__main__.IrisFlower object at 0x107774fd0>: 0.25999999999999945}

```

which is ok. But I do not want to create the dictionary first, and then append the key value, as in:

```
d = dict()
d[training_flower] = dist

```

So this is what I am trying:

```
d = dict(training_flower = dist)

```

However, it does not seem like the `dist` method is using the instance, but rather a String, because what I see printed is as follows:

```
{'training_flower': 23.409999999999997}
{'training_flower': 16.689999999999998}

```

How do I create the dictionary by using the object as key in one statement?