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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:32:13+00:00 2026-06-16T05:32:13+00:00

According to the Python (2.7) documentation : Due to the precarious circumstances under which

  • 0

According to the Python (2.7) documentation:

Due to the precarious circumstances under which __del__() methods are
invoked, exceptions that occur during their execution are ignored, and
a warning is printed to sys.stderr instead

What would be the most Pythonic way to completely and absolutely ignore an exception raised in __del__() — that is, not only having the exception ignored but also nothing printed to sterr. Is there a better way than temporarily redirecting stderr to the null device?

  • 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-16T05:32:14+00:00Added an answer on June 16, 2026 at 5:32 am

    I am assuming this is in a __del__() function that you are writing, if so, just catch the exception yourself and ignore it.

    def __del__(self):
        try:
            # do whatever you need to here
        except Exception:
            pass
    

    The logging to stderr only applies for uncaught exceptions in __del__().

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

Sidebar

Related Questions

According to the Python documentation on idioms and anti-idioms in relation to exceptions :
I'm trying to install dajax / dajaxice according to their documentation, which suggests that
According to Jython's documentation : Jython is an implementation of the Python language for
According to Python documentation, both dir() (without args) and locals() evaluates to the list
According to the Python documentation, only a few hash algorithms are guaranteed to be
According to the official Python documentation for the weakref module the primary use for
According to the documentation on python's getopt (I think) the options fields should behave
According to the documentation , if Django was installed manually like python setup.py install
I am using the MongoEngine map_reduce functionality in python. According to the MongoDB documentation
According to the python documentation exception OverflowError Raised when the result of an arithmetic

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.