[PATCH v2 4/8] python: Extract create_resource() helper