Iterate over object attributes in python [duplicate]

This question already has answers here: Is there a built-in function to print all the current properties and values of an object? (29 answers) Closed last year. I have a python object with several attributes and methods. I want to iterate over object attributes. class my_python_obj(object): attr1=’a’ attr2=’b’ attr3=’c’ def method1(self, etc, etc): #Statements I … Read more

Can every recursion be converted into iteration?

A reddit thread brought up an apparently interesting question: Tail recursive functions can trivially be converted into iterative functions. Other ones, can be transformed by using an explicit stack. Can every recursion be transformed into iteration? The (counter?)example in the post is the pair: (define (num-ways x y) (case ((= x 0) 1) ((= y … Read more

How to loop over grouped Pandas dataframe?

DataFrame: c_os_family_ss c_os_major_is l_customer_id_i 0 Windows 7 90418 1 Windows 7 90418 2 Windows 7 90418 Code: print df for name, group in df.groupby(‘l_customer_id_i’).agg(lambda x: ‘,’.join(x)): print name print group I’m trying to just loop over the aggregated data, but I get the error: ValueError: too many values to unpack @EdChum, here’s the expected output: … Read more