python - Defining __str__ and __repr__ for a set container -



python - Defining __str__ and __repr__ for a set container -

i have been working on big assignment , i'm finished except need help writing __str__ , __repr__ functions of set container.

i have never done , have no clue do. searching internet, i'm still stuck.

i've tried like:

'%s(%r)' % (self.__class__, self)

i need print out representation this:

'set([element_1, element_2,..., element_n])'

my elements stored in array class wrote set container around. access loop for item in self or if item in self

please help?

i suspect next work:

def __repr__(self): homecoming 'set([%s])' % ', '.join(self)

python string repr

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -