views:

57

answers:

4

If you look at the following line of python code:

bpy.ops.object.particle_system_add({"object":bpy.data.objects[2]})

you see that in the parameters there is something enclosed in braces. Can anyone tell me what the braces are for (generically anyway)? I haven't really seen this type of syntax in python and I can't find any documentation on it.

Any help is greatly appreciated. Thank you.

+2  A: 

The braces create a dictionary. particle_system_add seems to be accepting a dictionary as its argument.

Ned Batchelder
+1  A: 

It's just a dictionary with a single key/value pair of "object" as the key and whatever bpy.data.objects[2] evaluates to as the value.

whaley
+2  A: 

It's a dictionary.

Fred Larson
+6  A: 

From the docs:

Dictionaries can be created by placing a comma-separated list of key: value pairs within braces, for example: {'jack': 4098, 'sjoerd': 4127} or {4098: 'jack', 4127: 'sjoerd'}, or by the dict constructor.

Daniel Vassallo
Thank you very much.
Leif Andersen