Hello,
I'm using Python and I want to do a drag & drop interface.
For example, with a large picture whose size is bigger then the screen, I want to click on it and drag it to see other parts. Something like "google maps"!
In google maps if we click two times we do "zoom" but if we click one time and while pressed, we move the mouse, we...
Hello,
I have several directories and I want directories over 7 days old to be deleted. I have code already implemented but It doesn't seem to be working. Can anyone see where I am going wrong?
def delete_sandbox():
for directories in os.listdir(os.getcwd()):
if not os.path.isdir(directories) or not os.stat(directories)....
I'm trying to get a value from one of my database values, which will be given by subtracting the purchase date from today's date. I've written my code this way:
delta = datetime.now() - item.purchase_date
But this gives me this error:
unsupported operand type(s) for -: 'datetime.datetime' and 'datetime.date'
If I use datetime.date...
We need to choose between two signature schemes:
RSA/SHA2 S-MIME signatures
ECDSA/SHA2 S-MIME signatures
For that our python software needs to support one of this scheme. Currently for some political reasons the ECDSA solution is prefered.
Is the ECDSA solution supported by any of the python crypto modules (M2Crypto, ...) and do you...
This is ugly. How would you do it?
import datetime
t= (2010, 10, 2, 11, 4, 0, 2, 41, 0)
dt = datetime.datetime(t[0], t[1], t[2], t[3], t[4], t[5], t[6])
Thanks in advance.
...
I'm writing a simple auth system to login (and logout) users. The username is an email address, which looks up an email field.
I'm using:
user = User.objects.get(email__exact=email)
# if user obj exists
if user:
# if authenticate
if authenticate(user, email, password):
# create session
request.session['user'] = ...
When I serialize a list of objects with a custom __get__ method, __get__ is not called and the raw (unprocessed by custom __get__) value from __set__ is used. How does Python's json module iterate over an item?
Note: if I iterate over the list before serializing, the correct value returned by __get__ is used.
...
I'm working on a python plugin for Google Quick Search Box, and it's doing some odd things with non-ascii characters. It seems like the code works fine up until I try constructing a string containing the non-ascii characters (ü has been my test character). I am using the following code snippet for the construction, with new_task as the v...
def SiteAdminForm(model_cls, *args, **kwargs):
class MerchantAdminForm(forms.ModelForm):
class Meta:
exclude = ('external_links', 'published', 'logo','image_zip_file',)
model = model_cls
def __init__(self, *args, **kwargs):
super(MerchantAdminForm, self).__init__(*args, **kwargs)
...
I have this very simple program:
from win32com import client
ie=client.Dispatch("InternetExplorer.Application")
This used to work (I think I broke something when I re-used 'makepy.py' to try and add in constants for IE).
It still works on another machine where I haven't been so slap-dash with 'makepy.py'.
Here's what I get in an int...
Hi. Does anyone know a good parser for document metadata in python for unix like systems. In Java, apache tika is great.
No com ... please :)
Thanks
...
A simple question on a python module. Let's say I have the following code:
for i in range(1000):
print i
It'll output something along the lines of:
1
2
'Snip'
999
Is it possible to have the program output all the numbers on the same line? I'm not talking about "1, 2, 3 .." rather I want the line value to change ...
When I invoke add() on a tarfile object with a file path, the file is added to the tarball with directory hiearchy associated .In other words, if I unzip the tarfile the directories in the original dir hiearchy are reproduced.
Is there a way to simply add a plainfile without directory info that untarring the resulting tarball produce a ...
I've noticed two methods to "message passing". One I've seen Erlang use and the other is from Stackless Python. From what I understand here's the difference
Erlang Style - Messages are sent and queued into the mailbox of the receiving process. From there they are removed in a FIFO basis. Once the first process sends the message it is fr...
Is it better to use the "is" operator or the "==" operator to compare two numbers in Python?
Examples:
>>> a = 1
>>> a is 1
True
>>> a == 1
True
>>> a is 0
False
>>> a == 0
False
...
I need to create directories and files in a Samba share on Windows, from a Python script. I can (and do) also use .NET 3.5 from Python. I would like to create these directories and files with certain owners and permissions. Can I achieve this somehow?
...
I am fetching rows from the database and wish to populate a multi-dimensional dictionary.
The php version would be roughly this:
foreach($query as $rows):
$values[$rows->id][] = $rows->name;
endforeach;
return $values;
I can't seem to find out the following issues:
What is the python way to add keys to a dictionary using an au...
For the following Python code:
fp = open('output.txt', 'wb')
# Very big file, writes a lot of lines, n is a very large number
for i in range(1, n):
fp.write('something' * n)
fp.close()
The writing process above can last more than 30 min. Sometimes I get the error MemoryError. Is the content of the file before closing stored in mem...
I'm just getting started using Nose and Nosetests and my tests are failing because Nose can't see the environmental variables.
So far, the errors:
AttributeError: 'Settings' object has no attribute 'DJANGO_SETTINGS_MODULE'
I fixed this by exporting DJANGO_SETTINGS_MODULE from .bash_profile
export DJANGO_SETTINGS_MODULE="settings"
No...
I have strings containing numbers with their units, e.g. 2GB, 17ft, etc.
I would like to separate the number from the unit and create 2 different strings. Sometimes, there is a whitespace between them (e.g. 2 GB) and it's easy to do it using split(' ').
When they are together (e.g. 2GB), I would test every character until I find a lette...