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

?

Recommended Answers

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 …
Jump to Post

All 2 Replies

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.