Debugging Python with Visual Studio Code

Debugging Python with Visual Studio Code

I have started using Visual Studio Code, and to be honest, I feel it’s one of the best IDEs in the market. I’m still a Vimmer; given a chance I still use VIM for small edits or carrying out nifty text transformations. After Vim, the next tool that has really impressed me is VSC; the innovations the team are doing, the utility that it provides is almost a super power.

This post is regarding one of the utilities that I have been using very recently. This is a skill that I have been trying to harness for a long time. For every person who writes code there comes a time where they need to figure out what is going wrong;  there’s a need to debug the code.
The most prominent and well used debugging tools are print statements. To be really honest, it doesn’t feel (to me) quite right to use print statements to debug my code, but that’s the most handy way to figure out the flow and inspect each variable. I’ve tried a lot of debuggers and it alway feels like extra effort to actually take a step up and use them. This could be one of the reasons I might have not used them very intensively. (Although I have used pudb extensively.)

But, with VS Code, the way debugger is integrated in really well. It feels very natural to use it. Recently when I was working on few scripts and was trying to debug them, I went on exploring a little more with the python debugger in VS Code.

So I have this script and I want to run the debugger or it. You hit ctrl + alt + p, this opens the the command drop down, just type debug and you will see the option,  Debug and start debugging.


Screenshot 2018-06-24 22.45.31


This actually creates a launch.json file in your project. You can put all your configuration in here. We’ll edit the config file as we go; since it is not a Django or Flask project we will use the current file configuration. That looks like this:


"name":"Python: Current File",





You can set the pythonPath here if you are using a virtual environment, name sets the name of the configuration, type is the type of file, that is being debugged it, and  request can be used to debug it in different ways. Let’s make our configs more customised,

"name":"Facebook Achieve Debug",



"program": "${flle}"

Screenshot 2018-06-25 00.23.42
If you observe there’s a red dot at line 50.  That is called the breakpoint and that is where the program will stop and you will be able to observe variables and see the flow of the program.
Let’s see what the screen looks like when you do that,
Screenshot 2018-06-25 00.34.34
This is the editor in full flow, you could see the stack that is being followed, you can also go and inspect each variable.
With the debug console (lower right pane) you can even run some code that you want to run or to inspect the same. Now, let us look at the final config and see what is going on.


 "name":"Python: Current File",










If you observe I have the pythonPath set to my ​virtualenv and I have one more argument which is args which is the command-line  argument that has to be passed to the script.
I still use print statement sometimes but I have made it  a sure point to start using the debugger as early as possible because, believe it or not, this definitely helps a lot and saves time.

Home Theatre!

Due to a lot of turmoils in my life in the recent past, I had to shift with a friend. Abhinav has been an old friend and college mate, we have hacked on a lot of software and hardware projects together but this one is on of the coolest hack of all time and since we are flatmates now it solved a lot of issues. We also had his brother Abhishek so the hack became more fun.

The whole idea began with the thoughts of making the old laptops which we have to be used as servers, we just thought what can we do to make the best of the machines we have. He has already done few set ups but then we landed up on doing a htpc, it stands for Home Theatre PC or media centre, basically a one stop shop for all the need, movies, tv shows and music. And we came up with a nice arrangement which requires few things, the hardware we have:

  1. Dell Studio 1558
  2. Raspberry Pi 3
  3. And a TV to watch these on 😉

When we started configuring this setup we had a desktop version of Ubuntu 18.04 installed but we figured out that this was slowing down the machine so we switched to Ubuntu Server edition. This was some learning because I have never installed any server version of operating system. I use to wonder always what kind of interface will these versions give. Well without any doubt it just has a command-line utility for every thing, from partition to network connection.

Once the server was installed we just had to turn that server into a machine which can support our needs, basically installed few packages.

We landed up on something called as Atomic Toolkit. A big shoutout for the team to develop this amazing installed which has a ncurses like interface and can run anywhere. Using this toolkit we kind of installed and configured CouchePotato, Emby and Headphones.

This slideshow requires JavaScript.

This was more than enough we could automate a lot of things in our life with this kind of set up, from Silicon Valley to Mr. Robot. CouchePotato help us to get the best quality of videos and Emby gives us a nice dashboard to show all the content we have.

I don’t use Headphones much because I love another Music Application but then Headphones being a one stop shop is not wrong too. All this was done on the Dell Studio Machine we had, also we stuck a static IP on it so to know which IP to hit.

Our sever was up, running and configured. Now, we needed a client to listen to this server we kind of have a TV but that TV is not smart enough so we used a Raspberry Pi 3 and attached it to the TV using the HDMI port.

We installed OSMC on the Raspberry Pi and configured it to use Emby and listen to the Emby server once we booted it up it was very straight forward. This made our TV look good and also a little smart and it opened our ways for 1000s of movies, music and podcast. Although I don’t know if setting up this system was more fun or watching those movies will be.


                                                              गुरु गोबिंद दोऊ खड़े, का के लागूं पाय।
                                                                 बलिहारी गुरु आपणे, गोबिंद दियो मिलाय॥

Kabir tries to explain the importance of a good teacher in this Doha. I have had a few Gurus in my life, my mother being the first one, she taught me how to talk to others, how to respect others and many other life skills. In school I had many teachers but no Gurus, you might be thinking that this guy is crazy he is saying he had teachers but no Gurus. Well, the difference between Guru and a teacher is , Guru looks after your holistic growth.

I want to take today’s opportunity to talk about my mentors Gautham Sir and Lakshmi Ma’m. My association with them dated back to FSMK industrial training camp 2014 in short FSMK Summer Camp 2014. They were covering web technology and Jnaapti came to take JavaScript session that time. The way Gautham Sir took the session , it just blew me off.The motivation he gave us and the path he took to share the knowledge with us was different yet amazing , I became a fan at that time only. Jnaapti gave a free 30 days course on JavaScript and me being a fan didn’t want to loose any opportunity to learn from my hero hence I registered for the course.

JVC accounts were given to all of us and  Laksmi Ma’m war our coach for that course. I was so excited that I was clocking 20 hours of work which included college , travel and JVC. In between the course Ma’m said we have a surprise for whoever complete the course fastest, I somehow anticipated it will be an internship. “Working under the guidance of Gautham Sir”, that is  a dream come true for me. I can’t let that go so I tried harder to complete the course and I completed it. Ma’m asked me to send my resume to her (which is still pending :P). Then there were exams and I lost touch with Jnappti, I somehow gave exams and then pinged Ma’m on Hangout.

Ma’m said that you cannot take things for granted and the internship is over. I cannot put into words how bad I felt but then she told me that she was trying to teach me the importance of opportunity. Then I went to meet them at Jnaapti Home. I was scared and nervous but they are one of the most friendly people on earth. Finally I met Gautham Sir and Ma’m in person.

I can go on and on talking about various incidents and trust there are millions of those now. The best part is everytime I am talking to Sir , I am  gaining knowledge . It’s  like even he is talking to me about a very off topic discussion he is imparting me with knowledge , he is helping me to become a better person. He throws you challenges that you know you can’t but hr knows you can do it, it’s like a leap of faith. You just have to put your trust in Sir and just put your best foot forward. It is all about trying  and trying, he teaches you perseverance. He tells you it’s not about technology , it’s not about how much knowledge you have because you will never have enough. The whole point is, “Never give up!”

Our discussions have extreme points from future of computing to StartUp culture. He tells me about how your ideas shouldn’t be shallow enough. Your start up won’t succeed if you are shallow about it. He tells me the importance of putting your soul in your code. The videos we talk about, my favorite once are The Blue Shirt Guy and Randy Pausch . Both of those people saw world in different way and so do Sir. Whenever I feel low or I am happy I talk to him about it and he make sure that he brings me to the ground. He is my inspiration , he is one among those who I look upto, a friend, a mentor and a guide.

With Jnaapti I have grown a lot , I learnt a lot of things from analyzing personalities to learning how to learn. Ma’m on the other side is the sweet one. I can open my heart up and tell her whats bothering me and most of the time I don’t even have to say a word She like my mother knows it. She is a friend which I have so I am never alone. She pulls my leg whenever I come late and she joins me while pulling someones leg. She has taught me a lot , how to speak , how to express, what to say and when to say and most importantly how to convey things.

RDK sir is just awesome, he is one of the humblest person I met, he is a great friend , we crack most impossible jokes and discuss things which are really crazy.

For me It has been an amazing journey with Jnaapti, a lot of things has happened and Jnaapti is a second family for me because people care about each other here. The work is challenging and fun, it might look impossible at first but you just have to look beyond that.

Jnaapti a place where amazing happens. Thank you Sir and Ma’m for making me a part of this.