On 12/01/15 at 12:00pm, Steven D'Aprano wrote:
> I'm trying to understand why vars() exists. Does anyone use it?

Well, I have this little podcast aggregator
(https://github.com/manolomartinez/greg) that I and a bunch of other
people use. I started writing it some years ago, and the code is a bit
of a palimpsest, newer functionality reflecting my (somewhat) better
understanding of the language. One of the oldest bits is this main()
function:

        def main():  # parse the args and call whatever function was selected
                try:
                        args = parser.parse_args(sys.argv[1:])
                        args.func(vars(args))
                except AttributeError as err:
                        if str(err) == "\'Namespace\' object has no attribute 
\'func\'":
                                parser.print_help()
                        else:
                                print("Something has gone wrong: 
{}".format(err), file = sys.stderr, flush = True)
         

To judge by this thread, this is probably wrong/noobish?

Cheers,
Manolo
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to