You are viewing a single comment's thread from:
RE: Part 22: Calculate Account Value Based On Current Market Prices Via API
Nice! This could come in handy. Here are a few small pieces of advice to make the python even slicker.
Replace json.loads(response.content.decode('utf-8'))
with response.json()
in this line. Requests has a builtin function to parse JSON payloads.
Use Literal String Interpolation (f-strings) in the print statements at the end:
# Current code
print ("Steem: {:.3f}".format(liquid_steem))
# Suggested code
print(f"Steem: {liquid_steem:.3f}")
f-strings are only available in Python 3.6+, but you've specified 3.6 as a requirement! Yay for being up to date.
Finally, you may want to look into flake8 to help lint your code... it's pretty clean but there is some non-standard styling, like the spaces after the print statements and before the parenthesis.
Keep the #python #tutorials coming!
Hey @dhimmel
Here's a tip for your valuable feedback! @Utopian-io loves and incentivises informative comments.
Contributing on Utopian
Learn how to contribute on our website.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Much appreciated for the feedback! I will take it into account for the next tutorial.
very good tutorial python.