On Sun, Feb 27, 2011 at 6:58 AM, John <[email protected]> wrote:
> No, you just ran into a category loop. A is the main cat, B is a sub cat of
> A, so A>B>C>D>A is one type of example, this is fairly common in categories.

As a tip for future reference (e.g. in case someone googles this),
I've had good success using Python's built in set() objects for
handling this problem. They're fast and memory efficient.  So my code
goes something like:

seenCategories = set();
# then in my loop:
   if not cat.title() in seenCategories:
       seenCategories.add(cat.title());
       # do something with this category


Cheers,
Morten

_______________________________________________
Pywikipedia-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l

Reply via email to