Teaching myself Python Day 7

지난달

I have to admit todays code is mostly a copy from @felixx homework post. I did change the code to use the steemit api for the data as the default beem api timed out.

I also tried to run the program against the testnet, but it appears that @mytechtrail does not have any data in the database.

pylearnday7.png

from beem.account import Account
from beem.blockchain import Blockchain
from beem import Steem
from beem.instance import set_shared_steem_instance

#steemit_api = Steem(node=["https://testnet.steemitdev.com"])
steemit_api = Steem(node=["https://api.steemit.com"])
set_shared_steem_instance(steemit_api)

blockchain = Blockchain()
head_block = blockchain.get_current_block_num()

test_account = Account("mytechtrail")

rewards = []
reward_sum = 0

for curation_reward in test_account.history_reverse(start = head_block, stop = head_block - 30000, use_block_num = True, only_ops = "curation_reward"):
    rewards.append(curation_reward['reward']['amount'])

for reward_num in range(10): # starts at 0
    reward_sum += int(rewards[reward_num])
    print('\n', reward_num + 1, ':',  rewards[reward_num])

print('\naverage:', reward_sum/ 10, '\n... this look like its in VESTS ...')
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
STEEMKR.COM IS SPONSORED BY
ADVERTISEMENT
Sort Order:  trending

How is your experience so far? Never really got warm with python although I am working with C# and js a lot ^^

Posted using Partiko Android