MongoDB with Async Python Transcripts
Chapter: PyPI Beanie
Lecture: ClI REPL

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In order to do our loop here, what we're going to do is we're going to use a Python 3.10 feature, the match statement, kind of like a switch statement.
0:11 If you're using something lower than 3.10, 3.9 or below, just use if, else if, else if, else if.
0:16 Or you can use my switchlang package that adds the switch statement to older Python. You can find that on PyPI, by the way.
0:23 So what we're going to do is we're going to say match resp, like that.
0:29 And then we're going to have different cases. The case where it's S, I'm just going to print
0:33 summary real quick to show that this is working. We'll have a case for F. And let's say that we're calling a function here that doesn't yet exist.
0:53 So here we have it. S is going to show the summary. And I'll just have this print nothing for a minute,
1:01 just so we can get this, test this little section here. Let's run it again. Oh, look at this. We can enter a character for our command, let's say show.
1:17 So here you can see it would do the summary. We could do You should do nothing if we do ABC. So sorry, we don't understand that command.
1:27 Guess I could print out the command ABC, but then X, exit. Perfect, so we've got our REPL loop working.
1:34 Now we just have to go write all these functions, which will be fun. We get to play with the database and finally do all our queries.


Talk Python's Mastodon Michael Kennedy's Mastodon