Predictive Hacks

How to Refactor in VS Code

Assuming that you are working on a Python project and suddenly you decide to change the name of the function that is used in many files. To do this task manually is cumbersome. Let’s see how we can it efficiently using VS Code.

Assume that within a project, I have the following two .py files where we call a function called “my_function” that adds two numbers.

example.py

call_example.py

Let’s say, that I want to rename the “my_function” to “add_two“. With VS Code is easy. You just click on the “my_function” and then you right click and you choose the “Rename Symbol” and you type the new name, for example, “add_two”. As we can see, the name of the function has changed to both files!

Really cool, no?

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s