全 9 件のコメント

[–]djkris105 5ポイント6ポイント  (0子コメント)

I love this forum :>

[–]Workaphobia 4ポイント5ポイント  (9子コメント)

The title of this post suggests that you are deleting/replacing the last item of rule 1. In python, [:-1] means up to but not including the last item. The trial addendum should also be wrapped in a singleton list.

Pedantic Programmer Man, away!

[–]tskaiser[S] 3ポイント4ポイント  (6子コメント)

+/u/CompileBot python

rule0 = "All submitted content must be related to programming or programmers."
trial_addendum = ", or the title of the submission must substantially enhance" \
                 " the content such that it can stand on its own as an analogy"\
                 " to programming or programmers."

# other rules omitted, this is only an example
rule = [rule0]

# finally, we arrive at the title
rule[0] = rule[0][:-1] + trial_addendum

print rule[0]

[–]CompileBot 3ポイント4ポイント  (5子コメント)

Output:

All submitted content must be related to programming or programmers, or the title of the submission must substantially enhance the content such that it can stand on its own as an analogy to programming or programmers.

source | info | git | report

[–]tskaiser[S] 3ポイント4ポイント  (4子コメント)

Thank you.

[–]MokitTheOmniscient 3ポイント4ポイント  (0子コメント)

I have honestly never seen an internet argument won this decisively before.

[–]tskaiser[S] 2ポイント3ポイント  (1子コメント)

The [:-1] slice removes the punctuation mark of rule[0] before concatenating the two strings. The italics start with the comma. This is modeled, and tested, on Python 2.x.

edit: also works under Python 3.x

[–]Workaphobia 3ポイント4ポイント  (0子コメント)

Ah, I didn't realize it was so literal. I was taking the rule to be a sub-list rather than a string. I stand corrected.