Leif Andersen
Leif Andersen

Reputation: 22332

Parameters with braces in python

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.

Upvotes: 1

Views: 226

Answers (4)

Daniel Vassallo
Daniel Vassallo

Reputation: 344291

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.

Upvotes: 6

Fred Larson
Fred Larson

Reputation: 62063

It's a dictionary.

Upvotes: 2

whaley
whaley

Reputation: 16265

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.

Upvotes: 1

Ned Batchelder
Ned Batchelder

Reputation: 375554

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

Upvotes: 2

Related Questions