Viewing a response to: @xeroc/upvote-bot-in-less-than-10-lines-of-code
Hey @xeroc, love your stuff but I found a small bug with this logic: > if c["author"] in authors: This will be true for substring matches in authors. So if `authors` contains a name such as "longtestname" and `c["author"]` contains a name such as "name" or "test" It will evaluate as true (Python is still new for me)
author | discombobulated |
---|---|
permlink | re-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160809t225340625z |
category | steem |
json_metadata | {"tags":["steem"],"users":["xeroc"]} |
created | 2016-08-09 22:53:39 |
last_update | 2016-08-10 15:42:51 |
depth | 1 |
children | 3 |
last_payout | 2016-08-20 18:43:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.214 HBD |
curator_payout_value | 0.398 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 322 |
author_reputation | 13,090,894,039,053 |
root_title | "Upvote bot in less than 10 lines of code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 713,421 |
net_rshares | 2,054,141,131,590 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
anonymous | 0 | 28,850,488,570 | 1% | ||
boy | 0 | 2,463,907,793 | 100% | ||
xeroc | 0 | 1,975,079,749,104 | 100% | ||
bue-witness | 0 | 2,990,166,832 | 100% | ||
bunny | 0 | 571,974,504 | 100% | ||
bue | 0 | 41,271,539,830 | 100% | ||
mini | 0 | 1,320,931,169 | 100% | ||
moon | 0 | 167,039,189 | 100% | ||
healthcare | 0 | 490,152,439 | 100% | ||
daniel.pan | 0 | 705,422,677 | 100% | ||
helen.tan | 0 | 229,759,483 | 100% | ||
teddycool | 0 | 0 | 100% |
Thanks for taking a closer look, but since this expression "a" in ["aa"] evaluates to `False` in python, I'd say that python interprets all elements of `authors` independently and in full. That's because `authors` is an *array* or *list*. If it was just a single author then you would be right since "a" in "aa" evaluates to `True` Agreed?
author | xeroc |
---|---|
permlink | re-discombobulated-re-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160810t123419152z |
category | steem |
json_metadata | {"tags":["steem"]} |
created | 2016-08-10 12:34:18 |
last_update | 2016-08-10 12:35:18 |
depth | 2 |
children | 2 |
last_payout | 2016-08-20 18:43:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.018 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 353 |
author_reputation | 118,819,064,085,695 |
root_title | "Upvote bot in less than 10 lines of code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 723,481 |
net_rshares | 1,443,154,878,769 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
anonymous | 0 | 1,442,516,850,985 | 100% | ||
erikclark13 | 0 | 638,027,784 | 100% |
Just [tested this more](https://repl.it/languages/python3) and found out what the error was: If you include the single quotes around the array, both statements return True stringList = '["list","of","strings"]' print("list" in stringList) True print ("li" in stringList) True But if you remove the single quotes around the array, it functions as intended: stringList = ["list","of","strings"] print("list" in stringList) True print ("li" in stringList) False Hope this helps!
author | discombobulated |
---|---|
permlink | re-xeroc-re-discombobulated-re-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160810t154102727z |
category | steem |
json_metadata | {"tags":["steem"],"links":["https://repl.it/languages/python3"]} |
created | 2016-08-10 15:41:03 |
last_update | 2016-08-10 15:41:03 |
depth | 3 |
children | 1 |
last_payout | 2016-08-20 18:43:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.033 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 520 |
author_reputation | 13,090,894,039,053 |
root_title | "Upvote bot in less than 10 lines of code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 726,527 |
net_rshares | 66,969,783,339 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
discombobulated | 0 | 66,969,783,339 | 100% | ||
mex-power | 0 | 0 | 100% |
In the first case, the `stringList` is actually a simple string and is not interpreted as an array. that's why the test returns true in both cases.
author | xeroc |
---|---|
permlink | re-discombobulated-re-xeroc-re-discombobulated-re-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160811t065811793z |
category | steem |
json_metadata | {"tags":["steem"]} |
created | 2016-08-11 06:58:12 |
last_update | 2016-08-11 06:58:12 |
depth | 4 |
children | 0 |
last_payout | 2016-08-20 18:43:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.070 HBD |
curator_payout_value | 0.007 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 147 |
author_reputation | 118,819,064,085,695 |
root_title | "Upvote bot in less than 10 lines of code" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 741,182 |
net_rshares | 1,509,500,188,688 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
anonymous | 0 | 1,442,524,428,526 | 100% | ||
discombobulated | 0 | 66,975,760,162 | 100% | ||
donneker | 0 | 0 | 100% | ||
normaluser | 0 | 0 | 100% | ||
idealsceneprod | 0 | 0 | 100% | ||
jackeown | 0 | 0 | 100% |