Sorry for the bad title, my minds drawing a blank.
So I have an object that I want to print out all of the "printables" that it has, ie, everything not __. So I'm not sure how to go about doing this
So theres a lot of nonsense, since I'm just learning python. The last line is hopefully where there is just a nice and easy way to acces the item I want. I know that x1.a will just try to output the a item in x1, but I just had to try.Code:class ClassTest: def __init__(self): self.testing = 5 def func(self,rar): self.test = 3 def printer(self): print self.test def __add__(self,val): return self.test+val x1 = ClassTest() x2 = ClassTest() x1.func('asdfa') x2.func('aasdf') ClassTest.func(x1,'3') print x1+4 xa = 1 print dir(ClassTest) for a in dir(x1): try: print x1.a #What should go here except: pass
edit: On second thought, how about it tries to print everything?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks