piston-lib
piston-lib copied to clipboard
Could not convert string to float: '0.000 SBD'
The method get_comments() in the file post.py throws an error if the comments are sorted by total_payout_value (Python 3.5, Windows 10).
ValueError: could not convert string to float: '0.000 SBD'
I changed the method for me as follows:
def get_comments(self, sort="total_payout_value"):
""" Return **first-level** comments of the post.
"""
post_author, post_permlink = resolveIdentifier(self.identifier)
posts = self.steem.rpc.get_content_replies(post_author, post_permlink)
r = []
for post in posts:
r.append(Post(post, steem_instance=self.steem))
if sort == "total_payout_value":
r = sorted(r, key=lambda x: float(
x["total_payout_value"]**.replace(" SBD", "")**
), reverse=True)
elif sort == "total_payout_value":
r = sorted(r, key=lambda x: float(
x["total_payout_value"]**.replace(" SBD", "")**
), reverse=True)
else:
r = sorted(r, key=lambda x: x[sort])
return(r)
Of course this is just quick and dirty but it works for me until the devs fix it.