Question: I got a query result in array `Array ( [0] => stdClass Object ( [model] => Peugeot 308 SW ) [1] => stdClass Object ( [model] => Citroen C-Elysee ) [2] => stdClass Object ( [model] => Nissan Evalia ) [3] => stdClass Object ( [model] => Renault Trafic 9-os ) )`

And I want to make a single variable for every object like:

$Peugeot 308 SW  

$Citroen C-Elysee  

$Nissan Evalia

But I don't know how to do that. Thank you

Answer: 
You do not need to call `d.keys()`, so

```
if key not in d:
    d[key] = value

```

is enough. There is no clearer, more readable method.

You could update again with `dict.get()`, which would return an existing value if the key is already present:

```
d[key] = d.get(key, value)

```

but I strongly recommend against this; this is code golfing, hindering maintenance and readability.
With the following you can insert multiple values and also have default values but you're creating a new dictionary. 

```py
d = {**{ key: value }, **default_values}

```

I've tested it with the most voted answer and on average this is faster as it can be seen in the following example, .

[![Speed test comparing a for loop based method with a dict comprehension with unpack operator](https://i.stack.imgur.com/lxC54.png)](https://i.stack.imgur.com/lxC54.png)
Speed test comparing a for loop based method with a dict comprehension with unpack operator method.

if no copy (`d = default_vals.copy()`) is made on the first case then the most voted answer would be faster once we reach orders of magnitude of `10**5` and greater. Memory footprint of both methods are the same.