3

I answered a question.

Recently the answer has been deleted. Reason given is repost.

It claimed that my answer

The easiest solution I found so far is -

for stuff in largestring:
    if stuff.strip():
        print(stuff)

was repost of gimel's answer.

Try list comprehension and string.strip():

>>> mystr = "L1\nL2\n\nL3\nL4\n  \n\nL5"
>>> mystr.split('\n')
['L1', 'L2', '', 'L3', 'L4', '  ', '', 'L5']
>>> [line for line in mystr.split('\n') if line.strip() != '']
['L1', 'L2', 'L3', 'L4', 'L5']

What is the definition of repost?

I searched google, but could not get any answer.

6
  • 9
    I agree it's not exactly the same - and if anything it's closer to nmichael's answer, not gimel's answer - but the essence is the same: use a for loop / comprehension, and strip(). I suspect someone flagged it because you added a new answer to an old question with a few similar answers already. I've seen people get away with worse though.
    – Rup
    Commented Jul 23, 2020 at 8:53
  • 3
    see also: How aggressively should we maintain and improve very popular questions?
    – gnat
    Commented Jul 23, 2020 at 10:40
  • @gnat the two links you provided do not seem to have the word repost in them. Commented Jul 23, 2020 at 10:45
  • 7
    yes, because as far as I can tell your answer barely qualifies as repost. I would call it rehash, or, as dupe calls it "retread the same ground"
    – gnat
    Commented Jul 23, 2020 at 10:52
  • 2
    FWIW, 2 other answers on that question were deleted yesterday. Your answer is better than those 2. I probably wouldn't have cast a delete vote on it.
    – PM 2Ring
    Commented Jul 23, 2020 at 10:59
  • i thimnk also that is a repost of the other linked answer, besides it is not complete
    – nbk
    Commented Jul 23, 2020 at 11:36

1 Answer 1

12

Your answer isn't exactly a repost and I probably wouldn't have cast a delete vote on it.

But your answer is only a partial answer to the question, since it prints the non-blank lines, but it doesn't create a list of those lines, unlike gimel's answer.

(Another option would be to remove the blank lines from the list, but in Python that's generally less efficient than building a new list).


Your answer got caught up in a general clean-up of the answers on that old question. It's fairly common for old popular questions to gather new answers over the years. Sometimes, new answers are important because languages & libraries change, and so old answers can become invalidated, and new answers are necessary. But most of the time, the new answers don't add value to the page, they just add to the time it takes for people to find the useful material on the page. For further discussion on that topic, please see We need better tools to prevent "long tail of crap" on popular questions

3
  • Yes, I did some cleanups recently in response to long-waiting flags. Some were on questions flagged as having 30+ answers; others were custom flags by specific users about specific "duplicate" answers. I do believe in cleaning these up in a general sense, but, of course, not being a Python expert, I had to just take my best guess. It's not beyond possibility that I guessed wrong and inadvertently removing something that added value. If you see that, and want to second-guess me, that's fine. Ping me, raise another flag, or something.
    – Cody Gray Mod
    Commented Jul 23, 2020 at 17:48
  • @CodyGray You guessed well. ;) IMHO, blueray's answer didn't add value to that old question, but it would've been ok as an early answer on a fresh question. (I think it's fine to post partial answers, especially if you suspect it's a homework question & you just want to give the OP a nudge in the right direction and don't want to spoon-feed them code they can turn in as their own work).
    – PM 2Ring
    Commented Jul 23, 2020 at 18:00
  • 1
    Yeah, for sure. The cleanup crew gets called in when there are already plenty of other answers. (Although, do be careful on assuming what is or is not homework. You should always provide enough information so that the complete solution is within the grasp of a remotely competent programmer, otherwise you're not really compliant with our Q&A knowledge-base model. I'm a big fan of teaching someone how to fish, but once reading your answer, they should be drowning in fish. "Partial" is not really a good word for it.)
    – Cody Gray Mod
    Commented Jul 23, 2020 at 18:02

Not the answer you're looking for? Browse other questions tagged .