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

The Archive Base Latest Questions

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

I am following Apress, Beginning Python from Novice to Professional book. It is mentioned

  • 0

I am following Apress, Beginning Python from Novice to Professional book. It is mentioned that:

finally. You can use try/finally if you need to make sure that some
code (for example, cleanup code) is executed regardless of whether an
exception is raised or not. This code is then put in the finally
clause. Note that you cannot have both except clauses and a finally
clause in the same try statement—but you can put one inside the other.

I tried this code:

def someFunction():
    a = None
    try:
        a = 1 / 0
    except ZeroDivisionError, e:
        print 'Yesss'
        print e
    finally:
        print 'Cleanup'
        del a

if __name__ == '__main__':
    someFunction()

…and the output is

Yesss
integer division or modulo by zero
Cleanup

Here, I have used except and finally in the same try segment, haven’t I? And the code works fine as expected. I can’t quite get what the book says!

Someone please clarify. Thanks.

  • 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-25T20:34:15+00:00Added an answer on May 25, 2026 at 8:34 pm

    This has been fixed since python 2.5, and is clearly noted in the documentation

    In other words, your book is incorrect / out of date

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

Sidebar

Related Questions

I'm new to rails and am following the Apress 'Beginning Rails 3' book. I
I have been following the new Steve Sanderson MVC3 framework book from Apress and
I'm following the sportsStore tutorial from the Apress Pro Mvc 2 Framework book. It's
I am new to cakephp and have been working through the Apress book Beginning
I am trying to learn cocos2d for iphone, following the following book http://www.apress.com/9781430233039 .
I'm currently working through Apress's Beginning iPhone 3 Development. A standard they use in
trying to run the sample code in the Apress book called Beginning Scala. I
I've been following a tutorial McGugan - Beginning Game Development with Python and Pygame
I'm going through the Apress book Pro Core Data and it says the following:
Following on from my recent question on Large, Complex Objects as a Web Service

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.