473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dlaczego ten destruktor nie dziala

Mam klase A po ktorej dziedziczy B i jesli w destruktorze klasy B
wywolam:
self.__class__.__bases__[0].__del__(self)

to wszytkos jest ok, i destruktor klasy a jest wywolywany, jesli
natomiast napisze: A.__del__(self) to otrzymuje nastepujacy wyjatek:
Exception exceptions.AttributeError: "'NoneType' object has no
attribute '__del__'" in <bound method B.__del__ of <__main__.B instance
at 0x2b025d04a830>ignored

czemu tak sie dzieje?
Feb 4 '07 #1
4 3129
sorry, wrong group.
Feb 4 '07 #2
alf
Sulsa wrote:
sorry, wrong group.
the group is correct but language wrong, did you find out why the
exception pops up
Feb 6 '07 #3
Sulsa wrote:
Mam klase A po ktorej dziedziczy B i jesli w destruktorze klasy B
wywolam:
self.__class__.__bases__[0].__del__(self)

to wszytkos jest ok, i destruktor klasy a jest wywolywany, jesli
natomiast napisze: A.__del__(self) to otrzymuje nastepujacy wyjatek:
Exception exceptions.AttributeError: "'NoneType' object has no
attribute '__del__'" in <bound method B.__del__ of <__main__.B instance
at 0x2b025d04a830>ignored

czemu tak sie dzieje?
??

Cześć,
Właściewie to nie rozumiem sensu pytania. :)

Ja zrobiłem tak:

class A:
def __del__(self):
print "Delete A"

class B(A):
def __del__(self):
A.__del__(self)
print "Delete B"

potem sworzyłem instancję: InstanceB=B()

potem uruchomiłem destruktory: del(InstanceB) i moim oczom ukazał się
komunikat:

Delete A
Delete B

1) Czy atrybut A.__del__(self) zosatł zdefiniowany przez Ciebie?? Domyślny
nie jest brany pod uwagę. Sprawdziłem.

class A:
pass
class B(A):
def __del__(self):
A.__del__(self)
print "Cośtam"

potem

insta=B()
del(insta) daje Exception exceptions.AttributeError: "class A has no
attribute '__del__'" in <bound method B.__del__ of <__main__.B instance at
0xb7cf20cc>ignored

PS.: Python 2.4.4c1
Feb 6 '07 #4
>self.__class__.__bases__[0].__del__(self)
Swoją drogą to nie masz litości pisząc coś takiego ;)
Feb 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marcin | last post by:
Mam taki ciekawy problem. Wysylam e-maila z za³±cznikiem korzystaj±c z klas Mail::Send(); Wysy³am e-maila w sposób identyczny jak w przyk³adzie z dokumentacji tj. include('Mail.php');...
0
by: Mikolaj J | last post by:
Witam, szukając w dokumentacji mysqla odpowiedzi na moje pytanie trafiłem na taki przykład: SELECT user, MAX(salary) as max_sel FROM tmp GROUP BY user HAVING max_sel = MAX(salary); I...
1
by: schnitzell | last post by:
Witam, Mam nastêpujacy problem z fokusem. Zrobilem ActiveXa, wewnatrz, ktorego znajduja sie kontrolki, po ktorych chcialbym normalnie sie poruszac za pomoca Taba, jednak w zaleznosci od tego, do...
2
by: Tony Johansson | last post by:
Hello Experts!! I have two small classes called Intvektor and Matris shown at the bottom and a main. Class Intvektor will create a one dimension array of integer by allocate memory dynamically...
2
by: yopwojtek | last post by:
Hello All, i know from some tutorials, that copy constructor and assigment operator is not inherited from base to derived class. i think it make sense but i wrote a little example: class Base {...
0
by: Robert | last post by:
Witam, chcialbym uzyskac szablon, ktory bedzie zamienial liczebniki us na pl. Ponizszy szablon nie dziala ze zmienna 'us', komunikat: "Nie mozna uzyskac odwolania do zmiennej lub parametru 'us'....
4
by: Dariusz Tomon | last post by:
Hello, The situation is like follow: I've got GridView1 correlated with DetailsView1 (it's normal scenario). In DetailView1 I've got CRUD operations enabled. For create and edit opeartion...
1
by: vertigo | last post by:
Czesc Uzywam funkcji mail(). Server postfix skonfigurowany lokalnie dziala poprawnie i szybko. Jednak gdy w kodzie php uzywam funkcji mail() skrypt jest przetwarzany okolo 60 sekund (bez...
2
by: dariusz.sawicki | last post by:
Witam Dopiero zaczynam z js i mam taki problem: Waliduje pole peseljs i dla maska_p wszystko jest okej natomiast dla maska_p1 jest problem i nie mgoe tego rozgryzc;/ Js:
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.