create account

RE: Upvote bot in less than 10 lines of code by discombobulated

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @xeroc/upvote-bot-in-less-than-10-lines-of-code

· @discombobulated · (edited)
$1.61
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)
👍  , , , , , , , , , , ,
properties (23)
authordiscombobulated
permlinkre-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160809t225340625z
categorysteem
json_metadata{"tags":["steem"],"users":["xeroc"]}
created2016-08-09 22:53:39
last_update2016-08-10 15:42:51
depth1
children3
last_payout2016-08-20 18:43:12
cashout_time1969-12-31 23:59:59
total_payout_value1.214 HBD
curator_payout_value0.398 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length322
author_reputation13,090,894,039,053
root_title"Upvote bot in less than 10 lines of code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id713,421
net_rshares2,054,141,131,590
author_curate_reward""
vote details (12)
@xeroc · (edited)
$1.02
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?
👍  ,
properties (23)
authorxeroc
permlinkre-discombobulated-re-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160810t123419152z
categorysteem
json_metadata{"tags":["steem"]}
created2016-08-10 12:34:18
last_update2016-08-10 12:35:18
depth2
children2
last_payout2016-08-20 18:43:12
cashout_time1969-12-31 23:59:59
total_payout_value1.018 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length353
author_reputation118,819,064,085,695
root_title"Upvote bot in less than 10 lines of code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id723,481
net_rshares1,443,154,878,769
author_curate_reward""
vote details (2)
@discombobulated ·
$0.03
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!
👍  ,
properties (23)
authordiscombobulated
permlinkre-xeroc-re-discombobulated-re-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160810t154102727z
categorysteem
json_metadata{"tags":["steem"],"links":["https://repl.it/languages/python3"]}
created2016-08-10 15:41:03
last_update2016-08-10 15:41:03
depth3
children1
last_payout2016-08-20 18:43:12
cashout_time1969-12-31 23:59:59
total_payout_value0.033 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length520
author_reputation13,090,894,039,053
root_title"Upvote bot in less than 10 lines of code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id726,527
net_rshares66,969,783,339
author_curate_reward""
vote details (2)
@xeroc ·
$1.08
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.
👍  , , , , ,
properties (23)
authorxeroc
permlinkre-discombobulated-re-xeroc-re-discombobulated-re-xeroc-upvote-bot-in-less-than-10-lines-of-code-20160811t065811793z
categorysteem
json_metadata{"tags":["steem"]}
created2016-08-11 06:58:12
last_update2016-08-11 06:58:12
depth4
children0
last_payout2016-08-20 18:43:12
cashout_time1969-12-31 23:59:59
total_payout_value1.070 HBD
curator_payout_value0.007 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length147
author_reputation118,819,064,085,695
root_title"Upvote bot in less than 10 lines of code"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id741,182
net_rshares1,509,500,188,688
author_curate_reward""
vote details (6)