create account

Debugging Python in VS Code by themarkymark

View this thread on: hive.blogpeakd.comecency.com
· @themarkymark ·
$23.60
Debugging Python in VS Code
https://i.imgur.com/XSlci4K.png

Going to show you some examples of debugging Python with VS Code using the simple code here.

```
from beem import Hive
from beem.account import Account

hive = Hive()

me = Account('themarkymark')
print(me)
```

This code simply connects to the blockchain via Beem using the Hive object and creates an account object for the account 'themarkymark'.  Nothing complicated.

If you run it, you get the following output.

```
(base) C:\Users\mal\Desktop>python debugging.py
<Account themarkymark>
```

Nothing unexpected here.  Let's say we want to use the debugger to look at some details of the hive connection.  

First click the run in the left hand side.

https://i.imgur.com/ZOA43Oq.png

You will get a dialog asking if you want a custom launch file, for now let's just run & debug without one.

https://i.imgur.com/f53gOxX.png

Select the first option to debug the current python file.

https://i.imgur.com/N6TQbeh.png

You will notice the bottom bar goes red, and then nothing special happens.  That's because we haven't setup a breakpoint, let's do that now.  A breakpoint tells the debugger you want to pause execution here and inspect the environment.  Let's set a breakpoint right before the print statement.

https://i.imgur.com/paCQ0ZJ.png

Click right to the left of the 7 and a red dot will appear, let's try run & debug again.

At this point you can see the bar is red again, but the code execution is now paused.

https://i.imgur.com/VNZqg2z.png

On the left side you have three sections now, Variables, Watch, and Call Stack.

The variables section is what you will use most, it will allow you to inspect all current variables.  Watch section will allow you to predefine variables or expressions you want to monitor during execution.  Finally the call stack will display the current call stack.

Let's inspect the Hive local object.

https://i.imgur.com/KhLJpjL.png

Here you can get some information such as the current node, current hard fork, as well as a lot more information if you dig deep enough.  There is a lot of information in the hive connection object.  

You can use this menu bar in the top middle to stop your code, step forward one line, or continue.  

https://i.imgur.com/3SxyyrI.png

There are two ways to step forward in a debugger, **step into** and **step over**.  Step into will go into any function that is called and step each line of that function, step over will just move you to the output of functions.

Let's add a couple of variables, and inspect them as they are created.

```
from beem import Hive
from beem.account import Account

hive = Hive()

me = Account('themarkymark')

vesting_shares = me['vesting_shares']
received_vesting_shares = me['received_vesting_shares']
delegated_vesting_shares = me['delegated_vesting_shares']
```

Set up a break point at line 8 and run & debug.

https://i.imgur.com/76PsKMJ.png

Your code should stop right before we start assigning variables.

https://i.imgur.com/XHankeL.png

Let's hit the step into button to move one line forward.

https://i.imgur.com/CmrkDHv.png

You will notice our variables updated and we now have a **vesting_shares** variable with the amount of vesting shares on my account.

https://i.imgur.com/SQCe0dt.png

Hit step into two more times.

The 2nd time you will notice we got a receiving_vesting_shares variable and on the third it ended.  That's because the debugger got to the end of the code and exited.

This should give you enough information to do some basic debugging, in a future post I'll cover how to setup a launch file and watches.


---

<center>Securely chat with me on [Keybase](https://keybase.io/officialmarky)
<center>https://images.hive.blog/0x0/https://steemitimages.com/DQmcWxV1dpA1eAtw2ipwZiWZkydyVNU5LaLa2Ak1GUnbGmS/The-Marky-Mark.png </center>
# <center>  [Why you should vote me as witness](https://peakd.com/witness-category/@themarkymark/why-you-should-vote-for-themarkymark-as-witness)  </center> #

[![](https://steemitimages.com/DQmPkQhAQceC7aHr4Gy5GKv7LMoiy47P7PyaNCeZBHMpFke/white-bg-with-drop-shadow.gif)](https://hivesigner.com/sign/account-witness-vote?witness=themarkymark&approve=1)     


πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 354 others
πŸ‘Ž  , , , , , , ,
properties (23)
authorthemarkymark
permlinkdebugging-python-in-vs-code
categoryprogramming
json_metadata{"app":"peakd/2020.09.4","format":"markdown","tags":["programming","development","codewithmarky","technology","palnet","neoxian","vscode","tutorial"],"users":["themarkymark"],"links":["https://keybase.io/officialmarky","/witness-category/@themarkymark/why-you-should-vote-for-themarkymark-as-witness","https://hivesigner.com/sign/account-witness-vote?witness=themarkymark&amp;approve=1"],"image":["https://i.imgur.com/XSlci4K.png","https://i.imgur.com/ZOA43Oq.png","https://i.imgur.com/f53gOxX.png","https://i.imgur.com/N6TQbeh.png","https://i.imgur.com/paCQ0ZJ.png","https://i.imgur.com/VNZqg2z.png","https://i.imgur.com/KhLJpjL.png","https://i.imgur.com/3SxyyrI.png","https://i.imgur.com/76PsKMJ.png","https://i.imgur.com/XHankeL.png","https://i.imgur.com/CmrkDHv.png","https://i.imgur.com/SQCe0dt.png","https://steemitimages.com/DQmcWxV1dpA1eAtw2ipwZiWZkydyVNU5LaLa2Ak1GUnbGmS/The-Marky-Mark.png","https://steemitimages.com/DQmPkQhAQceC7aHr4Gy5GKv7LMoiy47P7PyaNCeZBHMpFke/white-bg-with-drop-shadow.gif"]}
created2020-09-15 03:47:21
last_update2020-09-15 03:47:21
depth0
children10
last_payout2020-09-22 03:47:21
cashout_time1969-12-31 23:59:59
total_payout_value14.202 HBD
curator_payout_value9.394 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,174
author_reputation1,669,691,348,878,083
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,634,146
net_rshares90,307,330,292,432
author_curate_reward""
vote details (426)
@akhyar23 ·
This good
properties (22)
authorakhyar23
permlinkre-themarkymark-2020915t111553315z
categoryprogramming
json_metadata{"tags":["programming","development","codewithmarky","technology","palnet","neoxian","vscode","tutorial"],"app":"ecency/3.0.4-mobile","format":"markdown+html"}
created2020-09-15 04:15:54
last_update2020-09-15 04:15:54
depth1
children0
last_payout2020-09-22 04:15:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation45,409,408,267,830
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,634,452
net_rshares0
@brianoflondon ·
I downloaded VSCode yesterday for the first time to start doing some python email stuff. Loving it. Definitely going to pick up and look at working with Hive. 
properties (22)
authorbrianoflondon
permlinkre-themarkymark-qgop16
categoryprogramming
json_metadata{"tags":["programming"],"app":"peakd/2020.09.4"}
created2020-09-15 05:10:18
last_update2020-09-15 05:10:18
depth1
children3
last_payout2020-09-22 05:10:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length159
author_reputation705,273,207,203,002
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,634,978
net_rshares0
@themarkymark ·
VS Code is really amazing and the only thing Microsoft has done right in many years. 
properties (22)
authorthemarkymark
permlinkre-brianoflondon-qgopb4
categoryprogramming
json_metadata{"tags":["programming"],"app":"peakd/2020.09.4"}
created2020-09-15 05:16:18
last_update2020-09-15 05:16:18
depth2
children2
last_payout2020-09-22 05:16:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length85
author_reputation1,669,691,348,878,083
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,635,040
net_rshares0
@brianoflondon ·
You know I've beaten up on MS for years too, but I have to say whilst the interface on Team sucks balls, the actual quality of the sound and video during calls is amazing.

Australia is using MS Teams for all court cases and it was flawless the other night.

This VSCode dev environment, synced with github, is pretty darn amazing.
properties (22)
authorbrianoflondon
permlinkre-themarkymark-qgov2g
categoryprogramming
json_metadata{"tags":["programming"],"app":"peakd/2020.09.4"}
created2020-09-15 07:20:48
last_update2020-09-15 07:20:48
depth3
children1
last_payout2020-09-22 07:20:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length331
author_reputation705,273,207,203,002
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,636,398
net_rshares0
@diyhub ·
<div class="pull-right"><a href="https://steempeak.com/trending/hive-189641"><img src="https://cdn.steemitimages.com/DQmV9e1dikviiK47vokoSCH3WjuGWrd6PScpsgEL8JBEZp5/icon_comments.png"></a></div>

###### Thank you for sharing this amazing post on HIVE!

- Your content got selected by our fellow curator @tibfox & you just received a little thank you via an upvote from our **non-profit** curation initiative!

- You will be **featured in** one of our recurring **curation compilations** and on our **pinterest** boards! Both are aiming to offer you a **stage to widen your audience** within and outside of the DIY scene of hive.

**Join** the official [DIYHub community on HIVE](https://peakd.com/trending/hive-189641) and show us more of your amazing work and feel free to connect with us and other DIYers via our [discord server](https://discord.gg/d2Ma444)!

If you want to support our goal to motivate other DIY/art/music/homesteading/... creators just delegate to us and earn 100% of your curation rewards!

###### Stay creative & hive on!
properties (22)
authordiyhub
permlinkre-debugging-python-in-vs-code-20200917t074524z
categoryprogramming
json_metadata"{"app": "beem/0.24.5"}"
created2020-09-17 07:45:24
last_update2020-09-17 07:45:24
depth1
children0
last_payout2020-09-24 07:45:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,044
author_reputation362,477,078,738,641
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,671,382
net_rshares0
@drniche ·
I am still using Pycharm. It is getting more and more confusing... I probably will need to dig into VS soon! Thank you for sharing. I am also wondering if beem can help extract attributes such as #followers/followings, etc.
properties (22)
authordrniche
permlinkqgpmw4
categoryprogramming
json_metadata{"tags":["followers"],"app":"hiveblog/0.1"}
created2020-09-15 17:21:39
last_update2020-09-15 17:21:39
depth1
children0
last_payout2020-09-22 17:21:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length223
author_reputation172,973,143,590
root_title"Debugging Python in VS Code"
beneficiaries
0.
accounthiveonboard
weight100
1.
accounttipu
weight100
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,644,211
net_rshares0
@gitplait ·
Upvoted by GITPLAIT!

We have a curation trial on Hive.vote. you can earn a passive income by delegating to @gitplait
We share 80 % of the curation rewards with the delegators.

To delegate, use the links or adjust 10HIVE, 20HIVE, 50HIVE, 100HIVE, 200HIVE, 500HIVE, 1,000HIVE, 10,000HIVE, 100,000HIVE

Join the Community and chat with us on Discord let’s solve problems & build together.
properties (22)
authorgitplait
permlinkqgprhf
categoryprogramming
json_metadata{"users":["gitplait"],"app":"hiveblog/0.1"}
created2020-09-15 19:01:24
last_update2020-09-15 19:01:24
depth1
children0
last_payout2020-09-22 19:01:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length387
author_reputation911,220,543,569
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,645,716
net_rshares0
@osakivolezka42 ·
Best signals, and trade bot! - https://jamm.to/
πŸ‘  
properties (23)
authorosakivolezka42
permlinkqgpf3k
categoryprogramming
json_metadata{"links":["https://jamm.to/"],"app":"hiveblog/0.1"}
created2020-09-15 14:33:21
last_update2020-09-15 14:33:21
depth1
children0
last_payout2020-09-22 14:33:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length47
author_reputation-526,183,582,894
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,641,607
net_rshares4,633,061,519
author_curate_reward""
vote details (1)
@steevc ·
I've heard that VS Code is good and I see it is available for Linux. I have used Visual Studio a fair bit for work and that is a powerful IDE. I need to check this out.
properties (22)
authorsteevc
permlinkre-themarkymark-qgp1t7
categoryprogramming
json_metadata{"tags":["programming"],"app":"peakd/2020.09.4"}
created2020-09-15 09:46:21
last_update2020-09-15 09:46:21
depth1
children0
last_payout2020-09-22 09:46:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length168
author_reputation1,046,997,581,239,586
root_title"Debugging Python in VS Code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,637,949
net_rshares0