Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

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

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.

Avatar image for nathank

nathank on Dec. 12, 2020

I thought I knew repr very well but this just adds an additional level of depth. Thanks Dan!

Avatar image for dbristow31

dbristow31 on Jan. 28, 2021

This has been helpful. I made a note to myself to include a repr method to all of my classes, moving forward.

Avatar image for jeffersongarciaor

jeffersongarciaor on Jan. 29, 2021

Just amazing to learn new stuffs. Thank you Dan for this tutorial.

Avatar image for shangcode

shangcode on Feb. 20, 2021

Learned a lot! 😀

Avatar image for Cavalcante

Cavalcante on March 18, 2021

That’s Gold! I have seen this use of __ str__ in django when you use the admin interface, but I did not know it worked undercover.

Thanks for the lesson.

Avatar image for amirrastkhadiv

amirrastkhadiv on April 7, 2021

That’s informative. Thanks Dan!

Avatar image for Espius Edwards

Espius Edwards on Sept. 3, 2021

Thank you for your concise tutorial!

Avatar image for François 江戸 D

François 江戸 D on Sept. 21, 2021

No sooner said than used, my last piece of code got cleaner :)

Avatar image for MakerMike369

MakerMike369 on March 7, 2022

Was looking for info for making a “Class template” of sorts. .__repr__() fits the bill nicely!

Avatar image for mckown

mckown on June 30, 2022

Excellent presentation! I learned quite a bit. Thanks!

Become a Member to join the conversation.