List Python Variables
How to list all variables in a Python script
#! /usr/bin/env python # @file getVars.py # Set FTP connection variables. dbname = 'DBNAME'; username = 'USERNAME' password = 'PASSWORD' host = 'LOCALHOST' for name in dir(): myvalue = eval(name) print name, "is", type(name), "and is equal to ", myvalue
Returns something like this (sorry, but one of my input filters is mangling this output)...
and is equal to __doc__ is and is equal to None __file__ is and is equal to ./getVars.py __name__ is and is equal to __main__ __package__ is and is equal to None dbname is and is equal to DBNAME host is and is equal to LOCALHOST password is and is equal to PASSWORD username is and is equal to USERNAME
Available Wiki Topics
The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.