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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:40:25+00:00 2026-05-24T04:40:25+00:00

Dive into Python: HTTP Web Services – class DefaultErrorHandler(urllib2.HTTPDefaultErrorHandler): def http_error_default(self, req, fp, code,

  • 0

Dive into Python: HTTP Web Services –

class DefaultErrorHandler(urllib2.HTTPDefaultErrorHandler):
    def http_error_default(self, req, fp, code, msg, headers):
        result = urllib2.HTTPError(
            req.get_full_url(), code, msg, headers, fp)
        result.status = code
        return result

HTTPError object initially has no attribute ‘status’, ie. status data attribute does NOT exist in HTTPError class definition. This means when I allocate memory for an instance of HTTPError, no allocation is made for status data attribute.

Then how can I on the fly create a status data attribute for the same instance in the next line? It seems something fascinating is going on beneath that I am unaware of which is giving python this flexibility which was never available in C++/Java


It’s a pity I didn’t catch this until Chapter 11.

  • 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-24T04:40:26+00:00Added an answer on May 24, 2026 at 4:40 am

    Python has a different notion of data types than C or Java. Python does not allocate memory for the data members of an instance if it is created. Instead, when an instance is created, it gets an __dict__ attribute pointing to a dictionary mapping attribute names to values. This dictionary is as dynamic as any standard Python dictionary. If you do

    result.status = code
    

    an entry with the key "status" and the value code is added to this dictionary.

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

Sidebar

Related Questions

Dive into Python: Scripts and Streams - class KantGenerator: def _load(self, source): sock =
Is there an online Java book like Dive into Python for learning Python? Other
Dive into Python - It would be tempting but incorrect to call this the
Dive into Python - Guido, the original author of Python, explains method overriding this
romantest.py : Dive into Python: Introducing romantest.py Dive into Python: Test-First Programming - $
After reading: Dive into Python: Unicode Discussion I got curious to try printing my
I'm working through 'Dive Into Python' on Google App Engine and came across this
I am learning python via dive into python. Got few questions and unable to
see: http://diveintopython.net/native_data_types/lists.html#d0e5623 I have a website with code examples on it, generated through docutils
I would like to pretty print out each key value pair from dictionaries which

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.