I'm working on a basic event form created from a model, but I keep getting the following error message:
TypeError at /addlaundry/
addlaundry() takes exactly 1 argument (0 given)
I think it's because I'm not passing the argument through on views, but I can't find documented anywhere how to do this right, at least not written in a way I...
How can one change the formatting of output from the logging module in Google App Engine?
I've tried, e.g.:
log_format = "* %(asctime)s %(levelname)-8s %(message)s"
date_format = "%a, %d %b %Y %H:%M:%S"
console = logging.StreamHandler()
fr = logging.Formatter(log_format)
console.setFormatter(fr)
logger = logging.getLogger...
I want to adjust the colour levels of an image in python. I can use any python library that can easily be installed on my Ubuntu desktop. I want to do the same as ImageMagick's -level ( http://www.imagemagick.org/www/command-line-options.html#level ). PIL (Python Image Library) doesn't seem to have it. I have been calling convert on the ...
Hi, I'm wondering if it's possible in Python to find a method in a different function by using it's string name.
In one function, I pass in a method:
def register(methods):
for m in methods:
messageType = m.__name__
python_client_socket.send(messageType)
register(Foo)
In a different method that takes in the stri...
If Python, if you are developing a system service that communicates with user applications through sockets, and you want to treat sockets connected by different users differently, how would you go about that?
If I know that all connecting sockets will be from localhost, is there a way to lookup through the OS (either on windows or linux...
Short of essentially rewriting copytree to accept an ignore callback, what is a simple way to achieve this in versions prior to python 2.6? (I don't want to stray from my debian packages)
...
TL/DR:
import gc, sys
print len(gc.get_objects()) # 4073 objects in memory
# Attempt to unload the module
import httplib
del sys.modules["httplib"]
httplib = None
gc.collect()
print len(gc.get_objects()) # 6745 objects in memory
UPDATE
I've contacted Python developers about this problem and indeed it's not going to be possible t...
Is there an python function similar to raw_input but that doesn't show a newline when you press enter. For example, when you press enter in a Forth prompt it doesn't show a newline.
Edit:
If I use the code:
data = raw_input('Prompt: ')
print data
than the output could be:
Prompt: Hello
Hello
because it printed a newline when I pres...
Possible Duplicate:
How to Learn Python
Hi,
What would be a good resource for a newbie like me who beginning Python programming?
Can you please think of any beginners python books that have help you become a professional python developer?
Best Answer:
Thanks for the redirections to relevant posts.
After reading them all, I...
I am dealing with some python code automatically generated for me. I want to avoid manually editing these python files & hence this question/issue:
foo.py:
def foo():
print "foo"
boo.py:
def boo():
foo.foo() # <-- global name 'foo' not defined
print "boo"
bar.py:
import foo
import boo
def bar():
boo.boo()
print "bar"...
So I know that you can wrap a function around another function by doing the following.
def foo(a=4,b=3):
return a+b
def bar(func,args):
return func(*args)
so if I then called
bar(foo,[2,3])
the return value would be 5.
I am wondering is there a way to use bar to call foo with foo(b=12) where bar would return 16?
Does this m...
Basically I have this xml element (xml.etree.ElementTree) and I want to POST it to a url. Currently I'm doing something like
xml_string = xml.etree.ElementTree.tostring(my_element)
data = urllib.urlencode({'xml': xml_string})
response = urllib2.urlopen(url, data)
I'm pretty sure that works and all, but was wondering if there is some ...
Musing over a recently asked question, I started to wonder if there is a really simple way to deal with XML documents in Python. A pythonic way, if you will.
Perhaps I can explain best if i give example: let's say the following - which i think is a good example of how XML is (mis)used in web services - is the response i get from http re...
I have a python class
class Vector2D(object):
def __init__(self, x, y):
self.x = float(x)
self.y = float(y)
def mag(self):
return sqrt(self.x**2 + self.y**2)
...
I want to be able to multiply vectors together like vector1 * vector2, so I added
def __mul__(self, v):
return Vector2D(se...
I am poking at XBRL documents trying to get my head around how to effectively extract and use the data. One thing I have been struggling with is making sure I use the context information correctly. Below is a snippet from one of the documents I am playing with (this is from Mattel's latest 10-K)
I want to be able to efficiently colle...
I know Python doesn't have pointers, but is there a way to have this yield 2 instead
>>> a = 1
>>> b = a # modify this line somehow so that b "points to" a
>>> a = 2
>>> b
1
?
Here's an example: I want form.data['field'] and form.field.value to always have the same value. It's not completely necessary, but I think it would be nice....
Hi, I had one machine with my commonly used python package installed.
and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a b...
I've read a number of questions on finding the colour palette of an image, but my problem is slightly different. I'm looking for images made up of pure colours: pictures of the open sky, colourful photo backgrounds, red brick walls etc.
So far I've used the App Engine Image.histogram() function to produce a histogram, filter out values ...
Recently, I want to optimize my code. Would any one tell how to speed up looping? While-loop is faster than for-loop? And which type of for-loop is faster?
It is surely I am not talking about a empty content looping. I mean If any good way to loop a huge data in Java or Python.
And I got the answer from here
...
Hi,
I am at wit's end. I have a working install of python 2.6.5 with numpy and scipy. I want to use it to do some simple PCA which requires importing images. Well, I figured PIL was the way to go for this. So, following a guide, I downloaded and installed libjpeg6-b. I then used the following commands
tar zxvf jpegsrc.v6b.tar.gz
cd jpe...