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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:26:01+00:00 2026-06-17T05:26:01+00:00

I need to know WHY this fails: class ConfigurationError(Exception): def __init__(self, *args): super(ConfigurationError, self).__init__(self,

  • 0

I need to know WHY this fails:

class ConfigurationError(Exception):
    def __init__(self, *args):
        super(ConfigurationError, self).__init__(self, args)

        self.args = list(args)
        # Do some formatting on the message string stored in self.args[0]
        self.args[0]=self.__prettyfi(self.args[0])

    def __prettyfi(self, arg):
        pass
        # Actual function splits message at word
        # boundaries at pos rfind(arg[1:78]) if len(arg) >78
        # it does this by converting a whitespace char to a \n

When I run the code, i receive the following msg:
<snip>
ConfigurationError.py", line 7, in __init__
self.args[0]=self.__prettyfi(self.args[0])
TypeError: 'tuple' object does not support item assignment

I edited the line no. to match this code sample.

I do not understand why self.args = list(args) does not correctly unpack the tuple into the list at line 5.

(I have a sneaking suspicion I am failing to remember something super-basic…)

  • 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-17T05:26:02+00:00Added an answer on June 17, 2026 at 5:26 am

    Exception.args is a descriptor; it hooks __set__ to turn anything you assign to self.args into a tuple.

    So, as soon as you assign your list to self.args, the descriptor converts it back to a tuple. It’s not that your list() call failed, it’s just that Exception.args is special.

    BaseException.args is documented to be a tuple, and in Python 2, exception objects support slicing:

    >>> ex = Exception(1, 2)
    >>> ex.args
    (1, 2)
    >>> ex[0]
    1
    

    Exceptions are also supposed to be immutable; keeping the .args attribute a tuple helps keep them so. Moreover, the __str__ handler for exceptions expects .args to be a tuple, and setting it to something else has led to strange bugs in the past.

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

Sidebar

Related Questions

I know this works very well: def locations(city, *other_cities): print(city, other_cities) Now I need
Need to know this so that i could send DTMF and that is going
I know this sounds like a dumb question but I need to ask this.
I know this question is difficult to understand but I need a mathematical equation
I know this is a very broadly scoped question, but what do I need
I need to know when I click on an element if this element has
I have this JQuery code working however I need to know whether how to
Go ahead and let me know if this is not possible: I need to
I don't know if this is a right question, but i need to understand
I have solved this problem, I just need to know what to do. I

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.