Print variable values by their names

Robert Brewer fumanchu at
Mon Oct 18 19:16:52 CEST 2004

Michael Krasnyk wrote:
> import sys
> for str in dir(sys): print str
> Will be printed only variable names, but I need values from 
> list of variable names.

import sys
for name in dir(sys):
    print name, getattr(sys, name)

Robert Brewer
Amor Ministries
fumanchu at

More information about the Python-list mailing list