[BangPypers] how to delete base class attribute
Nitin Kumar
nitin.nitp at gmail.com
Sat Jul 31 20:41:39 CEST 2010
Thanks Jeffrey,
I have one more query, but i am not able to explain you.
will send u a mail in few min.
Thanks
On Sat, Jul 31, 2010 at 11:57 PM, Jeffrey Jose <jeffjosejeff at gmail.com>wrote:
> On Thu, Jul 29, 2010 at 3:13 PM, Mehndi, Sibtey
> <sibtey.mehndi at genpact.com>wrote:
>
> > 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
> >
>
> To add to what Sibtey already finely explained,
>
> The only valid use case of del/ __del__ happens to be cleaning up the
> namespace if you're writing a module. Every other use case of del/__del__
> might or might not work.
>
> /jeff
>
>
> >
> > -----Original Message-----
> > From: bangpypers-bounces+sibtey.mehndi=genpact.com at python.org [mailto:
> > bangpypers-bounces+sibtey.mehndi <bangpypers-bounces%2Bsibtey.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.
> >
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
--
Nitin K
More information about the BangPypers
mailing list