GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python3-files/reverse-file at master · prashanthreddyp/python3-files

Expand file tree

/

reverse-file

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
32 lines (22 loc) · 667 Bytes
/

reverse-file

Copy path

File metadata and controls

executable file
·
32 lines (22 loc) · 667 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3.7
import argparse
import sys
parser = argparse.ArgumentParser()
parser.add_argument("filename", help="the file to read")
parser.add_argument("--limit", "-1", type=int, help="the number of lines to read")
parser.add_argument("--version", "-v", action="version", version="%(prog)s 1.0")
args = parser.parse_args()
try:
f = open(args.filename)
limit = args.limit
except FileNotFoundError as err:
print(f"Error: {err}")
sys.exit(2)
else:
with f:
lines = f.readlines()
lines.reverse()
if limit:
lines = lines[:limit]
for line in lines:
print(line.strip()[::-1])
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.