del Questions
2
Solved
I'm using an object's __del__() to unsubscribe it from an event (using an event scheme similar to this):
import my_enviroment
class MyClass():
def __del__(self):
my_environment.events.my_event -...
3
Solved
class ToBeDeleted:
def __init__(self, value):
self.value = val
# Whatever...
def __del__(self):
print self.value
l = [ToBeDeleted(i) for i in range(3)]
del l
This prints 2, 1, 0.
Now,...
1
Solved
Lets assume we have a class in python:
class A(object):
def __del__(self):
print "Del!"
__del__ is called upon deleting/garbage collection of any A instance.
Is is possible to do the same fo...
2
Solved
I tend to use it whenever I am working on a prototype script, and:
Use a somewhat common variable (such as fileCount), and
Have a large method (20+ lines), and
Do not use classes or namespaces ye...
3
Supose you have something like:
x = "something"
b = x
l = [b]
How can you delete the object only having one reference, say x?
del x won't do the trick; the object is still reachable from b, for...
Politi asked 10/6, 2010 at 9:48
2
Solved
I am new to python and have been working through the examples in Swaroop CH's "A Byte of Python". I am seeing some behavior with the __del__ method that is puzzling me.
Basically, if I run the fo...
Sometimes asked 20/12, 2009 at 7:42
3
link text
I got the concept of reference count
So when i do a "del astrd" ,reference count drops to zero and astrd gets collected by gc ?
This is the sample codes.These codes I developed after m...
4
Solved
I had always assumed that a file would leak if it was opened without being closed, but I just verified that if I enter the following lines of code, the file will close:
>>> f = open('some...
Search asked 22/2, 2009 at 17:26
© 2022 - 2024 — McMap. All rights reserved.