PS9 I wrote this method for ShapeSet. This method will work but gives me this error.
Traceback (most recent call last):
File "", line 1, in
TypeError: __str__ returned non-string (type NoneType)
I think it I need to return not print but I don't know how do that. any ideas
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Not the answer you are looking for? Search for more explanations.
forgot to say, when you give the print command you are telling Python to go find and execute the __str__ variable for whatever object you called.
whoops, __str__ method I mean
ok that makes sense but I thought that I wanted to write a __str__ which returns the string representation for the set, which consists of the string representation of each shape categorized by type. To do that I would need to loop and print. If I did 'return' that would end the loop before I all the shapes have been printed, right?
It is possible I don't understand the question fully. Does the question really want me to set up a str so that when I could use __iter__ to print? However, If I set it up like this It would not print all the shape categorized by type. Or does categorized by type really just mean that I need to set __str__ up in a way that calls the respected class definition up the chain.
well this is what I came up with, I don't know if this is the best way to do it but it does work.
something happened between me copying and posting the code. here is what I ment to post.
REAL CODE: http://dpaste.com/531160/