From the course: AI-Powered Development: GitHub Copilot in Visual Studio Code

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Code completion: Python

Code completion: Python

We just looked at how JavaScript code completion works with Copilot. Copilot offers the same functionality in most code editors so I thought it would be interesting to look at creating these same functions this time in a Python file. I'll start by using the def keyword to define a function. Isn't that interesting? The first suggestion is a function named format date. What's What's happening here is that Copilot is using context from my open files, recent edits, and comments. If it detects similar logic, it may proactively offer a translated version, even if I didn't explicitly ask for it. Also, notice it's using Python naming conventions. That's because Copilot adapts its suggestions to match the styling conventions of the language I'm working in. Notice that the word format underscore date and the parameter are in italicized text. That means that's the suggested text. So I'll press the tab key to accept that. And now Copilot is suggesting the rest of the function. So press tab a…

Contents