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 7840167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:40:58+00:00 2026-06-02T15:40:58+00:00

I am wondering if python has its error report message equivalent to $! in

  • 0

I am wondering if python has its error report message equivalent to $! in perl ?
Anyone who could give me an answer will be greatly appreciated.

Added:

example% ./test
File "./test", line 7
  test1 = test.Test(dir)
  ^
SyntaxError: invalid syntax

When Exception occurs, I got something like this. If I apply try and catch block,
I can catch it and use sys.exit(message) to log the message. But, is there any chance
that I can get the string SyntaxError: invalid syntax and put it in message

  • 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-06-02T15:41:01+00:00Added an answer on June 2, 2026 at 3:41 pm

    Python generally uses exceptions to report errors. If some OS operation returns an error code, it raises an exception that you catch in a try-except block. For OS operations, that is OSError. The errno is contained in the exception instance.

    from __future__ import print_function
    import os
    
    try:
            os.stat("xxx")
    except OSError as err:
            print (err)
            # The "err" object is on instance of OSError. It supports indexing, with the first element as the errno value.
            print(err[0])
    

    Output:

    [Errno 2] No such file or directory: 'xxx'
    2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if anyone have a good resource for working with Corba in Python?
I have a Python client-server application and its server has been running for about
I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has
So i am starting with python and was wondering how i could substitute numbers
Anyone has a link or best practices for handling Unicode characters across python applications?
I am wondering if python has any function such as php empty function (http://php.net/manual/en/function.empty.php)
Just wondering if there is a Python MTA . I took a look at
Just wondering whats the best way to test Python CGI while developing a site?
I have been wondering about the reload() function in python, which seems like it
I'm pretty new at python and I was wondering if this: def func(self, foo):

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.