import sys
def main():
pass
if __name__ == '__main__':
main()
class MyOtherClass:
def __init__(self):
self.test= "a"
self.test2= "b"
class MyClass:
def __init__(self):
self.name = "Name"
self.age = 30
self.other = "unknown";
self.complicated = MyOtherClass()
def printIt(aVar):
from pprint import pprint
if (hasattr(aVar, "__dict__")):
pprint (vars(aVar), sys.stdout, 4, 60, 3)
else:
pprint (aVar, sys.stdout, 4, 60, 3)
test4 = [1,2,3,4,8]
test2 = dict();
test2["1"] = 2
test2["2"] = 3
test = MyClass();
printIt(test4)
printIt(test2)
printIt(test)
9200cookie-checkPrint an object in Python