Related Information
To learn more, you can check out the following resources:
- Python 3’s f-strings: An Improved String Formatting Syntax
- Logging in Python
- Adding Unit Tests
- Understanding the Python Mock Object Library
- Python Debugging with pdb
- How to Flush the Output of the Python Print Function
Here are some useful external Python libraries you can check out to up your terminal interface game:
ncurses / curses
: terminal manipulationurwid
: TUI building toolkitcolored
: ANSI color printingbullet
: interactive command-line promptsprompt-toolkit
: interactive command-line application toolkitquestionnaire
: tools for creating command-line questionnaires
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
Thanks for sticking with me through this long journey through print()
and some of it’s related mechanisms inside of Python. Over the last 11 topics, you’ve looked at how to use the basic concepts of print()
; how to format strings; how to use sep
, end
, and flush
to control when it prints end lines, how it prints between objects, and when it flushes the buffer; how to print to files and stderr
(standard error). In Lesson 5, I talked about adding .__str__()
(dunder string) and .__repr__()
(dunder repr
) to your classes so that it behaves better with print()
.
00:28
I moved on to the difference between the print
statement in Python 2 and print()
functions in Python 3, and the cool things you can do with dependency injection now that it is a built-in function. After that, I showed you pretty printing. Lessons 8 and 9 showed you how to use escape sequences to control color, font weight, and do simple animation. Lessons 10 and 11 looked at debugging in unit tests and the complications print()
can cause therein. In this final lesson, I’m just going to be touching on other places you can go to drill down more on some of the things you’ve learned. First off, there are plenty of courses on Real Python that cover in-depth a lot of the concepts that I’ve gone over just briefly.
01:07
There are several courses on f-strings and how they were introduced into Python 3. There’s a deep dive into Python logging. There’s full courses on unit tests and how to use mocks inside of your unit tests. And finally, how to use a tool like pdb
to up your debugging game.
01:26
Additionally, there are some libraries you might want to look at to help you along your journey. I mentioned earlier the ncurses
, curses
, and urwid
libraries.
01:34
They help you do screen manipulation, TUI building, and animation of your cursors. There’s a library called colored
, which can help you do ANSI color printing and fancy ANSI mechanisms without having to write your own escape mechanism. And finally, bullet
, prompt-toolkit
, and questionnaire
are tools to help you write command-line code, making interactive prompts and questionnaires far easier to write.
02:00 Thanks for your attention! I hope you found the content useful.
Cristian Palau on May 6, 2020
Thanks for the course!
Walt94 on May 7, 2020
I wondered how they did text interfaces. I will look at curses
Good course!
mbonilla on May 9, 2020
Thanks Christopher, great course.
Simon Keating on May 12, 2020
Thank you for the course, lots of great new directions to explore with logging and debugging.
Anonymous on May 28, 2020
who know print() could do so much! thank you!
Santosh on July 5, 2020
print(70*’Beautiful! ‘)
paolotagliente on July 16, 2020
great stuff, so much info and well explained!! thanks and great work, keep up!
Ghani on Oct. 24, 2020
Excellent course; thank you so much!
cosmicaug on Feb. 16, 2021
Very good.
Note that there’s possibly a small typo on the last slide. I think the last slide’s references to “nurses” is meant as a reference to ncurses (the BSD implementation that the curses module is based on), as mentioned in the 8th slide.
Christopher Trudeau RP Team on Feb. 17, 2021
Hi @csmicaug,
Yep, ncurse you autocorrect. :) We’ll get on a fix. Thanks. …ct
cosmicaug on Feb. 18, 2021
I like the idea of a nurses module in the standard library. Maybe it could be used to provide some methods that would tend your wounds after you try linting your code?
Become a Member to join the conversation.
Vignesh Anand Krishnan on May 5, 2020
great video.