Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6997163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:14:56+00:00 2026-05-27T20:14:56+00:00

Here is code from a tutorial in A Byte of Python: import sys filename

  • 0

Here is code from a tutorial in A Byte of Python:

import sys

filename = 'poem.txt'

def readfile(filename):
    #Print a file to standard output
    f = file(filename)
    while True:
        line = f.readline()
        if len(line) == 0:
            break
        print line,
    f.close()

if len(sys.argv) < 2:
    print 'No action specified'
    sys.exit() //<--This is where the error is occurring

if sys.argv[1].startswith('--'):
    option = sys.argv[1][2:] #fetches sys.argv[1] without first 2 char
    if option == 'version':
        print 'Version 1.2'

    elif option == 'help':
        print '''\
This program prints files to the standard output.
Any number of files can be specified.
Options include:
    --version: Prints the version number
    --help: Displays this help'''

    else:
        print 'Unknown option'
    sys.exit()

else:
    for filename in sys.argv[1:]:
        readfile(filename)

When I run this code, this is the error that appears:

Traceback (most recent call last):
  File "C:/Python/sysmodulepr.py", line 17, in <module>
    sys.exit()
SystemExit

I don’t understand why. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:14:56+00:00Added an answer on May 27, 2026 at 8:14 pm

    It’s telling you that sys.exit() has executed on line 17 of your program.

    The entry for for sys.exit in the Python documentation tells you that this exits your program.

    There’s no way this line can execute without producing other output, so I think there’s something missing in the question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document()
I have got the following code from here to read an Excel file using
Here's a snippet of code from within TurboGears 1.0.6: [dispatch.generic(MultiorderGenericFunction)] def run_with_transaction(func, *args, **kw):
Here is my code: from League.models import Leagues from League.models import Team from django.contrib
Here is my following tutorial code from Learning PHP MYSQL and Javascript by OReilly.
i have this code from t he django sample tutorial from django.db import models
Here is code from MSDN . I don't understand why the work isn't just
Here's the code from the ascx that has the repeater: <asp:Repeater ID=ListOfEmails runat=server >
I'm using some code from here to determine when determining when the last finger
I found this code from here: http://www.cssportal.com/form-elements/text-box.htm But the problem is you can still

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.