[BangPypers] how to delete base class attribute
Mehndi, Sibtey
sibtey.mehndi at genpact.com
Thu Jul 29 11:43:32 CEST 2010
Nitin,
del can only remove the elements present in the instance dictionary. If you check self.__dict__ then it shows that A is not in the dictionary only 'a' and 'b' exist in the dict that's why it is giving the attribute error.
Sibtey
-----Original Message-----
From: bangpypers-bounces+sibtey.mehndi=genpact.com at python.org [mailto:bangpypers-bounces+sibtey.mehndi=genpact.com at python.org] On Behalf Of Nitin Kumar
Sent: Thursday, July 29, 2010 2:18 PM
To: Bangalore Python Users Group - India
Subject: [BangPypers] how to delete base class attribute
Hi all,
Say I have 10 functions in base class and I have inherited it in some
derived class.
But I only want 9 of the base class function to be available in child class.
(and I don't want to make that one class private)
class x:
def __init__(self):
self.a =3
self.b= 4
def A(self):
print (self.a)
def B(self):
print (self.b)
class y(x):
def __init__(self):
x.__init__(self)
del (self.A) #This is giving del
(self.A)
AttributeError: A
Anticipating your reply soon.
--
Nitin K
_______________________________________________
BangPypers mailing list
BangPypers at python.org
http://mail.python.org/mailman/listinfo/bangpypers
This e-mail (and any attachments), is confidential and may be privileged. It may be read, copied and used only
by intended recipients. Unauthorized access to this e-mail (or attachments) and disclosure or copying of its
contents or any action taken in reliance on it is unlawful. Unintended recipients must notify the sender immediately
by e-mail/phone & delete it from their system without making any copies or disclosing it to a third person.
More information about the BangPypers
mailing list