Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

String Conversion for Python Containers (Lists, Dicts, …)

Give Feedback

This is the final lesson in the course. In it, you’ll see how containers like lists and tuples convert their children to strings when called with str(). The lesson also encourages you to add a __repr__ method to your classes.

michelnakhla on July 20, 2019

Very brief and nice.

paulakula11 on Aug. 28, 2019

concise and clear

Silver on Dec. 7, 2019

awesome!

Lokman on Feb. 27, 2020

Thanks @DanBader for best practice always provide __repr__ for classes. I guess dunder repr short form for represent.

sroux53 on June 5, 2020

Excellent!

Vaibhav Kumar on July 19, 2020

Very well crisp and concise.

avalidzy on July 23, 2020

Excellent voice delivery! The “dunder” use methodology is more apparent to me. Thanks Dan!

Idris Diba on Aug. 3, 2020

I learned a lot from this tutorial. Thank you Dan for your excellent method of teaching.

vikrant06 on Aug. 16, 2020

neat

Ghani on Oct. 7, 2020

Very good though very short!

cap-gnc on Oct. 9, 2020

Thank you. __str__ vs __repr__ demystified.

geultrin on Nov. 5, 2020

Thanks Dan. Short and sweet. I knew about dunder repr but did not understand it fully. I now see its usefulness

loopology on Nov. 29, 2020

This tutorial is from 2017 and it shows: It’s using “{}”.format() instead of the f”{}” string formatting.

What I miss about all RealPython tutorials: They should state their publication date up front as well as the Python version being used, and possibly what would need to be changed to be up to date.

Abderraouf Z on Nov. 30, 2020

Top explanations!

Become a Member to join the conversation.