Skip to content
Advertisement

Syntax for nested dictionaries in Python

I’m developing Python scripts for the automated grading of assignments using CanvasAPI, an API wrapper in Python for the Canvas learning management platform. In studying the documentation, I can successfully issue curl commands in Python for a few parameters. For example, this conversion below is for uploading rubric information for a single submission:

Curl command per the Canvas API docs:

JavaScript

with:

JavaScript

Turns into this via the CanvasAPI Python wrapper

JavaScript

However, I’m having difficulty with the syntax for adding additional parameters, which creates what appears to be nested dictionaries. For example, if I wanted to add a text comment along with grade points, the API documentation offers this:

JavaScript

For which I’ve attempted:

JavaScript

which generates a syntax error:

JavaScript

I’ve also attempted:

JavaScript

which generates this error:

JavaScript

What is the proper way to structure the syntax to pass both parameters? Many thanks for any insights and assistance.

Advertisement

Answer

from rubric_assessment[criterion_id][comments], it looks like you need, edit(rubric_assessment={'criterion_#':{'points': 'point #','comments':'comment_text'}})

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement