3 ms·
python -c "print '\n'.join(open('file.txt').readlines()[::-1])" Hmmm, slightly longer then the Perl version ;-) python -c "print '\n'.join(reversed(list(ope
by Luyt 17y ago
python -c "print '\n'.join(open('file.txt').readlines()[::-1])"
Hmmm, slightly longer then the Perl version ;-)
python -c "print '\n'.join(reversed(list(open('test.py'))))"
Somewhat more elegant, but still lots of parentheses.
- RiderOfGiraffes 17y agoIt's also wrong - "readlines" keeps the "\n", and you've added another one between lines.