On 09/15/2010 10:00 AM, Peter Otten wrote:
def extract_names(t, recurse=1):
     for _, name, fmt, _ in t._formatter_parser():
         if name is not None:
             yield name
         if recurse and fmt is not None:
             for name in extract_names(fmt, recurse-1):
                 yield name

Thanks Peter, I very much like this generator solution. It will work for all situations I can currently think of.

However, one thing remains. It is based on the _format_parser method. And as I wrote in my original post this one - since it starts with _ - suggests to me to better not be used. So if using this method is completely ok, why does it start with _, why is it almost undocumented? Or did I miss something, some docs somewhere?

Best regards


Andre

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to