I was looking at this question and started wondering what does the print actually do.
I have never found out how to use string.decode() and string.encode() to get an unicode string "out" in the python interactive shell in the same format as the print does. No matter what I do, I get either
UnicodeEncodeError or
the escaped string wit...
I've seen a few threaded downloaders online, and even a few multi-part downloaders (HTTP).
I haven't seen them together as a class/function.
If any of you have a class/function lying around, that I can just drop into any of my applications where I need to grab multiple files, I'd be much obliged.
If there is there a library/framework ...
I am trying to use py2exe to distribute a python application I have written. Everything seems to go OK, but when I run it on another machine it fails with the following error:
Traceback (most recent call last):
File "application.py", line 12, in <module>
File "win32api.pyc", line 12, in <module>
File "win32api.pyc", line 10, in _...
Hi,
I got a big set of molecules from the zinc database (http://zinc.docking.org/), in mol2 (http://tripos.com/index.php?family=modules,SimplePage,,,&page=sup_mol2&s=0) format. I would like to be able to split this database into an arbitrary set of N smaller databases. What is the best scripting approach in either python, bash o...
hello .
i have 2 questions :
1- im trying to implement an ( Observer ) design pattern in python.
what is the easiest implementation for that ?
i need it to observe machines status in a render farm that im building currently .
2- is there any good (python) design patterns book out there ?
...
I have a fairly complex Django project which makes it hard/impossible to use fixtures for loading data.
What I would like to do is to load a database dump from the production database server after all tables has bene created by the testrunner and before the actual tests start running.
I've tried various "magic" in MyTestCase.setUp(), b...
Hi
I created extensions for my python and created a abcPython.dll
How can I import this dll into my python scripts.
I get an error message When I try to import it usin the following command
import abcPython
Error messgae
Traceback (most recent call last):
File "", line 1, in
Imp...
I'm using python to programatically download a zip file from a web server. Using a web browser, it's fine. I've written this (partial) script;
response = urllib2.urlopen(url, data, 10)
the_page = response.read()
f = open(filename, 'w')
f.write(the_page)
f.close()
The request succeeds and I get data. The problem is that the file I'm do...
Hello
Assume I have such simple model:
class Foo(models.Model):
name = models.CharField(max_length=25)
b_date = models.DateField()
Now assume that my query result from Foo.objects.all() , I retrieve something like this:
[
{'name': 'zed', 'b_date': '2009-12-23'},
{'name': 'amy', 'b_date': '2009-12-6'},
{'name': 'j...
Hello.
I have a few checkboxes with common name and individual variables (ID).
How can I in python read them as list?
Now I'm using
checkbox= request.POST["common_name"]
It isn't work properly, checkbox variable store only the last checked box instead of any list or something.
...
minidom, again.
tried
document.doctype = xml.dom.minidom.DocumentType('html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"')
There is no doctype in the output. How to fix without inserting it by hand?
...
I'm trying to install the module mySQLdb on a windows vista 64 (amd) machine.
I've installed python on a different folder other than suggested by Python installer.
When I try to install the .exe mySQLdb installer, it can't find python 2.5 and it halts the installation.
Is there anyway to supply the installer with the correct python loca...
If a software project supports a version of Python that multiprocessing has been backported to, is there any reason to use threading.Lock over multiprocessing.Lock? Would a multiprocessing lock not be thread safe as well?
For that matter, is there a reason to use any synchronization primitives from threading that are also in multiproce...
Hello
How can I achieve this using the Django template system:
Say I have 2 variable passed to the template system:
days=[1,2,3,4,5]
items=[ {name:"apple,day:3},{name:"orange,day:5} ]
I want to have such output as a table:
1 2 3 4 5
apple n n y n n
orange n n n n y
As you can notice, gi...
I want to load an image but I get an error-message.
My code:
from PIL import Image
im = Image.open("D:\Python26\PYTHON-PROGRAMME\bild.jpg")
im.show()
I get this error:
Traceback (most recent call last):
File "D:\Python26\PYTHON-PROGRAMME\00000000000000000", line 2, in <module>
im = Image.open("D:\Python26\PYTHON-PROGRAMME\bild...
A friend was "burned" when starting to learn Python, and now sees the language as perhaps fatally flawed.
He was using a library and changed the value of an object's attribute (the class being in the library), but he used the wrong abbreviation for the attribute name. It took him "forever" to figure out what was wrong. His objection t...
This code didn't show my picture. The picture really exists :)
Does anybody know why this doesnt work?
Thanks in advance!
from PIL import Image
im = Image.open("D:\\Python26\\PYTHON-PROGRAMME\\bild.jpg")
im.show()
...
Let's say that you have the following code:
import sqlite3
conn = sqlite3.connect('mydb')
cur = conn.cursor()
# some database actions
cur.close()
conn.close()
# more code below
If I try to use the conn or cur objects later on, how could I tell that they are closed? I cannot find a .isclosed() method or anything like it.
...
I have a class I've written in C#. The class has two methods, the signatures being:
bool Navigate(string url)
bool Navigate(Uri url)
From what I gather, the IronPython runtime is supposed to try and select the best overload based on the passed-in argument. In my case, I'm passing in a string which I know to be non-null, yet I get the ...
Hello,
say I have such model:
class Foo(models.Model):
name = models.CharField("name",max_length=25)
type = models.IntegerField("type number")
after doing some query like Foo.objects.filter(), I want to group the query result as such:
[ [{"name":"jb","type:"whiskey"},{"name":"jack daniels","type:"whiskey"}],
[{"name":"absolute","...