This is the output of my python prompt working by bot into it:wikisource (where: Poemi and Romanzi are two category names; list_in_cat is a simple python routine which returns the list of articles into a category; Georgiche is the name of a page, a poem):
>>> "Georgiche" in list_in_cat("Poemi")
Getting [[Categoria:Poemi]]...
True
>>> "Georgiche" in list_in_cat("Romanzi")
Getting [[Categoria:Romanzi]]...
False
>>>
Do you need something like this?