hey guys.
I am trying to get my libjpeg working with python with little or no luck.
I have followed this tutorial to get it up and running http://blaolao.com/setting-up-django-mysql-mysql-python-pil-etc on my 10.6, worked like a charm
now that I am looking at getting this onto my server I am getting stuck
I believe it already had lib...
Is it possible in python to sort a list of words not according to the english alphabet but according to a self created alphabet.
...
I have dictionary that is built as part of the initialization of my object. I know that it will not change during the lifetime of the object. The dictionary maps keys to sets. I want to convert all the values from sets to frozensets, to make sure they do not get changed. Currently I do that like this:
for key in self.my_dict.iterkeys():...
How do I add hooks to the Django Admin, such that I can execute a function when the user logs in or out?
...
How do I escape the % from a mysql query in python.
For example
query = """SELECT DATE_FORMAT(date_time,'%Y-%m') AS dd
FROM some_table
WHERE some_col = %s
AND other_col = %s;"""
cur.execute(query, (pram1, pram2))
gives me a "ValueError: unsupported format character 'Y'" exception.
How do I get mysqldb to ignore the %? Can't see thi...
Hi,
I've written a Python GUI application and made it run on Linux, Windows and Mac.
The framework I'm using is PyGtk.
The final result is not really good: the application looks horrible on Mac, and it is not really 'native' neither on Windows. Furthermore on Mac the windows' behavior is sometimes wrong, with modal dialogs appearing bel...
Hi,
someone can tell me why this is incorrect as a singleton pattern:
class preSingleton(object):
def __call__(self):
return self
singleton = preSingleton()
# singleton is actually the singleton
a = singleton()
b = singleton()
print a==b
a.var_in_a = 100
b.var_in_b = 'hello'
print a.var_in_b
print b.var_in_a
Edit:...
Hi,
I need to find all invocations of some logging macros in the code. The macro invocation is of the form:
DEBUG[1-5] ( "methodName: the logged message", arguments)
But the new versions of the macros are prepending the name of the method automatically, so my task is to write a Python script that will remove the duplicate function na...
When researching for this question and reading the sourcecode in random.py, I started wondering whether randrange and randint really behave as "advertised". I am very much inclined to believe so, but the way I read it, randrange is essentially implemented as
start + int(random.random()*(stop-start))
(assuming integer values for start ...
Function Annotations: PEP-3107
I ran across a snippet of code demonstrating Python3's function annotations. The concept is simple but I can't think of why these were implemented in Python3 or any good uses for them. Perhaps SO can enlighten me?
How it works:
def foo(a: 'x', b: 5 + 6, c: list) -> max(2, 9):
... function body ...
...
I found that even modern Python versions (like 3.x) are not able to detect BOM on text files. I would like to know if there is any module that could add this missing feature to Python by replacing the open() and codecs.open() functions for reading and writing text files.
...
I would like to install my python application as a command line tool that should work entirelly inside the install directory (for example C:\Python26\Lib\site-packages\application)
The problem is I would like to reffer in runtime to the submodules and resources from within the application directory three. If I install the app with [cons...
Hi I m following the tutorial on http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02 in windows 7 envoirement. my settings file is
TEMPLATE_DIRS = (
'C:/django-project/myapp/mytemplates/admin'
)
i got the base_template from the template admin/base_site.html from within the default Django admin template direc...
I use the module mechanize in order to log in a site. When I import twill.commands without any other apparent use, some debug messages [0] are displayed [1]. When I delete it, these messages disappear.
How can I see what is changed in the environment in order to emulate it and remove this dependency?
[0] Using the logging module.
[1] M...
hello,
recently i want to upload GAppProxy to GAE.
but when i use the appcfg.py to update the files,there comes an error,it was:
urllib2.URLError: urlopen error [Errno 8] _ssl.c:480: EOF occurred in
violation of protocol
i don't know why
PS:i live in china,and may be because of the GFW.
and when i use the type :appengine.google.com an...
When studying a snippet of unknown Python code, I occasionally bump into the
varName.methodName()
pattern.
To figure out what's this, I shall study the code more, find where varName was instantiated, find its type. So if varName proves to be an instance of ClassName class, I would knew that methodName() is a method of ClassName.
Som...
The following code with fail in Python 3.x with TypeError: must be str, not bytes because now encode() returns bytes and print() expects only str.
#!/usr/bin/python
from __future__ import print_function
str2 = "some unicode text"
print(str2.encode('raw_unicode_escape'))
How can you print a Unicode string escaped representation using p...
I'm looking to find a way to in real-time find the shortest path between nodes in a huge graph. It has hundreds of thousands of vertices and millions of edges. I know this question has been asked before and I guess the answer is to use a breadth-first search, but I'm more interested in to know what software you can use to implement it. F...
Hello,
I am trying to replace a string with a new string in a python file and write the new string permanently to it. When I run the below script it removes part of the string and not all of it. The string in the file is:
self.id = "027FC8EBC2D1"
And the script I have to replace the string is:
def edit():
o = open("test.py","r+...
I have written a small function, which uses ElementTree and xpath to extract the text contents of certain elements in an xml file:
#!/usr/bin/env python2.5
import doctest
from xml.etree import ElementTree
from StringIO import StringIO
def parse_xml_etree(sin, xpath):
"""
Takes as input a stream containing XML and an XPath expression...