I was wondering how do you mix list and dict together on Python? I know on PHP, I can do something like this:
$options = array(
"option1",
"option2",
"option3" => array("meta1", "meta2", "meta3"),
"option4"
);
The problem is python have different bracket for different list. () for tuple, [] for list, and {} for dict. There don't seems to be any way to mix them and I'm keep getting syntax errors.
I am using python 2.7 now. Please advice how to do it correctly.
Much thanks,
Rufas
Update 1:
I'll slightly elaborate what I'm trying to do. I am trying to write a simple python script to do some API requests here:
http://www.diffbot.com/products/automatic/article/
The relevant part is the fields query parameters. It is something like ...&fields=meta,querystring,images(url,caption)... . So the above array can be written as (in PHP)
$fields = array(
'meta',
'querystring',
'images' => array('url', 'caption')
);
And the $fields will be passed to a method for processing. The result will be returned, like this:
$json = diffbot->get("article", $url, $fields);
The thing is - I have no problem in writing it in PHP, but when I try to write it in Python, the thing is not as easy as it seems...