i'd like to do some cleanup whenever an instance is deleted at runtime, but not during garbage collection that happens on exit.
in the example below, when c is deleted, a file is removed, and this is what i want;
however, that file is also removed when the program exits, and this is NOT what i want.
class C:
def __del__(self):
os...
Hi all,
According to the docs I should be able to simply define this in my ~/.pydistutils.cfg and be off and running.
[install]
install-base=$HOME
install-purelib=python/lib
install-platlib=python/lib.$PLAT
install-scripts=python/scripts
install-data=python/data
But - when I do this I simply get this error...
error: install-base ...
Could someone tell me why this doesn't work?
def selectAndCopy(x,y,z,w):
ctypes.windll.user32.SetCursorPos(x,y)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0)
time.sleep(1)
ctypes.windll.user32.SetCursorPos(z,w)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, ...
So I have kind of a ignorant (maybe?) question. I'm working with writing to a serial device for the first time. I have a frame [12, 0, 0, 0, 0, 0, 0, 0, 7, 0, X, Y] that I need to send. X and Y are checksum values. My understanding in using the pyserial module is that I need to convert this frame into a string representation. Ok that's f...
Because cross-domain xmlrpc requests are not possible in JavaScript
I need to create a Python app which exposes both some HTML through HTTP and an XML-RPC service on the same domain.
Creating an HTTP request handler and SimpleXMLRPCServer in python is quite easy,
but they both have to listen on a different port, which means a different ...
I'm playing around with 2 objects {@link http://docs.python.org/library/datetime.html#datetime.date}
I would like to calculate all the days between them, assuming that date 1 >= date 2, and print them out. Here is an example what I would like to achieve. But I don't think this is efficient at all. Is there a better way to do this?
# ...
On Mac OSX 10.6.4 where do you install dynamic libraries (dylib) so Python 2.6.1 can import them? I've tried placing them in /usr/local/lib and usr/localbin and /Library/Python/2.6/site-packages but none of these locations have worked. The library I'm trying to install is libevecache.dylib a library to access cache files for Eve-Online.
...
this is similar to the question in http://stackoverflow.com/questions/3559807/merge-sort-in-python
I'm restating because I don't think I explained the problem very well over there.
basically I have a series of about 1000 files all containing domain names. altogether the data is > 1gig so I'm trying to avoid loading all the data into r...
I'm doing Zed Shaw's fantastic Learn Python The Hard Way, but an extra question has me stumped: Line 9--10 could be written in one line, how? I've tried some different thoughts, but to no avail. I could move on, but what would the fun in that be?
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print "...
I am essentially creating a blog application in django as a way of learning the ropes and boosting my skill level in django. I basically have a many-to-many relationship that I am having problems with in the admin site. I have two main types, Article and ArticleTag. Many Articles can belong to many ArticleTags, and the relationship shoul...
i am saying
s1="some very long string............"
and it gives me the above mentioned error
anyone konw what i am doing wrong?
...
i have quotes inside a string like this
string1="blah blah blah " some' thi'ng " end of string "
how do i make sure the quotes are included in there?
please note i have both doubel and single quotes in there
...
I have tried this probably 6 or 7 different ways, such as using various attribute values, XPath, id pattern matching (it always matches ":\w\w"), etc. as locators, and nothing has worked. If anyone can give me a tested, confirmed-working locator string for this button, I'd be much obliged.
...
i want it match only the end of every word
example:
"i am test-ing., i am test.ing-, i am_, test_ing,"
output should be:
"i am test-ing i am test.ing i am test_ing"
...
Sorry if the title is not very clear. I was not sure about the appropriate title. Let me explain what I need.
I am doing multiple runs of a simulation, where each run corresponds to a different seed. However, I want the starting characteristics of the instances of a class to remain the same across the different runs. For example, consi...
I'm trying to output the following data in my django templates.
Countries would be ordered descending by # of stories.
Cities would be ordered descending by # of stories (under that country)
Country A(# of stories)
City A (# of stories)
City B (# of stories)
Country B(# of stories)
City A (# of stories)
City B (# of stories)
...
want to count the number of times a letter appears in a string, having issues here. any help
def countLetters(string, character):
count = 0
for character in string:
if character == character:
count = count + 1
print count
...
I'm using the django admin calendar widget and would like to do highlight specific dates within the widget for display.
Is there a way to do this with the built-in django calendar widget?
Or, is there recommended widget that could be incorporated into a django project for this purpose?
...
I've been searching on this but am coming up a little short on exactly how to do specifically what i am trying to do.. I want to concatentate a string (I guess it would be a string in this case as it has a variable and string) such as below, where I need to use a variable consisting of a string to call a listname that has an index (from ...
In other words, I want to do something like
A[[-1, 0, 1], [2, 3, 4]] += np.ones((3, 3))
instead of
A[-1:3, 2:5] += np.ones((1, 3))
A[0:2, 2:5] += np.ones((2, 3))
...