November 16, 2019 HomeArticlesPython Tutorial: str() vs repr() Python Tutorial: str() vs repr() By George Tseng Articles 27 Comments Tags:computer science, development, how to, programming, Programming Language, Python, Python (Programming Language), Python Repr, Python Str, Python Tutorial, Python Tutorials, Repr, software, Software Engineering, Str, technology, Video Tutorial Related Posts The “1 Billion Dollar Morning Routine” – Habits of the World’s Most Successful People What Does Bitcoin Need to Succeed as a Currency? [POLICYbrief] Emilia Clarke Told One Person How ‘Game Of Thrones’ Ends About Author admin 27 Comments basant soni nice explanation November 1, 2015 Reply Ed James-Beckham Yours is a good explanation in very little time. December 15, 2015 Reply Nick Miller This is a perfect explanation. Nice work! June 20, 2016 Reply ali61442 thank you so much for good explanation. August 13, 2016 Reply Swadhikar C very clear explanation. You nailed it again! March 26, 2017 Reply Ravi Teja when strings 'a' and 'b' are both identical, how come repr function on a and b yields different results? June 13, 2017 Reply Michael The examples with datetime are very good. Thanks! 😀 July 6, 2017 Reply swaroop gv Not clear with the repr , can you explain it with more example December 29, 2017 Reply EadgCrunch Thank you for your work Corey. Your tutorials is perfect, minimalistic peace of art. I like your pronunciation, it’s very clear and 100% understandable. Your video is very compressed, without needless rumble and self promotion. I always wonder, how can you put so much information in such a short time. Brilliant, is what it is! January 6, 2018 Reply mountain scott Great video! Could you explain why "pytz.UTC" didn't show up when you ran "repr"? February 23, 2018 Reply viheren I cringe when i see U****y using your videos for adds February 25, 2018 Reply Nikita Pardeshi Got difference between str and repr. But having one question. str is a class and _str_ is a method. Even if str is a class, how we can easily write str(some object). Can you elaborate how str(some object ) works fine. April 1, 2018 Reply Howard Heitner Great tutorials, although often I have to pause them to digest the material. That is not a complaint as I would rather that then waiting for the commentator to get to the point. What editor are you using when you show the examples? April 23, 2018 Reply Jeff M. Your explanation while sufficient, really missing how powerful _str__ is April 25, 2018 Reply Ruslan Skira Put some small home task with solving at the and. Maybe it will be even more halpfull .Thank yo fo your work June 29, 2018 Reply Manik Dhingra Hello Corey! You do an amazing job at explaining complex things in a straight forward way. I started these videos and got addicted to it. Thanks for sharing. QQ – You mentioned that repr is for coders and help them in debugging. To that point, what repr is doing can be done with type(). Type(a) will return datetime.datetime and type(b) will return str. So my question is why to use repr. Do you mind sharing another example to make it more clearer. Thanks! September 14, 2018 Reply Dennis Parks hey Corey, I have python 3.7 installed and it doesn't recognize the pytz library. Is pytz for older versions? November 9, 2018 Reply Aghiad Alzein Great explanation , you've saved my day… November 14, 2018 Reply Slayer Awesome tutorial! Now I learned that python interpreter returns "repr()" instead of "str()". This made me to reflect a philosophy involving python debugging. I can understand the importance of the usability of repr(), since now.Thanks very much for sharing this. December 29, 2018 Reply Soccercrazyigboman Still don't get it. They both return a string no? January 21, 2019 Reply AST Space Nicely explained and thank January 27, 2019 Reply Too Late Cant, you just look at the type of the return value? February 7, 2019 Reply Solidwater Slayer first three minutes is: its very hard to determind the difference between str and repr via the ways people tried before getting to dis video aka documentation and testing no fucking shit its very hard to determind just hurry tf up and tell me wtf the difference is longest intro ever April 23, 2019 Reply FxStreamer repr returns a string of the whole line without executing the code but str returns a string of the result . why would you not show the a and b variables in your example? Thats literally makes it harder to understand .Also at 6:27 when you are explaining this simple thing you dont make any sense. June 1, 2019 Reply MatthewMusto very good video, thank you for this July 4, 2019 Reply Chris Keo Still dont get it August 12, 2019 Reply Linda Phan Thank you for sharing great knowledge! October 27, 2019 Reply Add a Comment Cancel reply Your email address will not be published. Required fields are marked *Comment:*Name:* Email Address:* Save my name, email, and website in this browser for the next time I comment.