Skip to content
This repository was archived by the owner on Mar 23, 2020. It is now read-only.
This repository was archived by the owner on Mar 23, 2020. It is now read-only.

Could not convert string to float: '0.000 SBD' #51

@Pythonix

Description

@Pythonix

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions