If I am creating an exception class, along with a stack

class CustomError(Exception):
	def __init__(self):
		self.contents=[]
		print "Stack Created"

How can I make it so that if

x=CustomError()

,
the stack contents will be

x.historical.contents

, not

x.contents

?

I don't understand completely what you're trying to do so this might not be helpful at all, but I feel bad cuz no one's tried to give you an answer.

you would need to make another class to save the attribute 'contents'

class container(object):
    pass

class CustomError(Exception):
	def __init__(self):
                self.historical = container()
		self.historical.contents=[]
		print "Stack Created"

*untested code

As someone mentioned in another thread (Computer Science): It is important to get clarification when the spec is ambiguous. The OP (original poster) has not asked a specific question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.