First time poster, long time reader, so bear with me:
Python decorators are fun to use, but I appear to have hit a wall due to the way arguments are passed to decorators. Here I have a decorator defined as part of a base class (the decorator will access class members hence it will require the self parameter).
class SubSystem(object):
...
When trying to use py2exe to convert a simple Python game I made into exe format, it gave me the following error:
Traceback (most recent call last):
File "C:\Users\Tali\Desktop\2exe.py", line 4, in <module>
setup(console=['test.py'])
File "C:\Python\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Py...
We've worked hard to work up a full dimensional database model of our problem, and now it's time to start coding. Our previous projects have used hand-crafted queries constructed by string manipulation.
Is there any best/standard practice for interfacing between python and a complex database layout?
I've briefly evaluated SQLAlchemy, S...
I am using reportlab in python to render a pdf server side.
I really like the look of highcharts graphs. But I am building a pdf server side which needs to include some graphs. The server side graphing (reportlab and matplotlib) do not have nearly as much choices for formatting / design.
Is there a way I can run a client side javas...
So I installed pydiction into vim for autocompleting my python code in windows. No problemo. Worked like a charm.
Tried the same thing with my Ubuntu setup, creating the .vim/after/ftplugin directory in my home folder and updating the vimrc with the correct path of the pydiction dictionary but I fail every time. Why is that ? I follow ...
Why did the Python designers decide that subclasses' __init__() methods don't automatically call the __init__() methods of their superclasses, as in some other languages? Is the Pythonic and recommended idiom really like the following?
def Superclass(object):
def __init__(self):
print 'Do something'
def Subclass(Superclass)...
Possible Duplicate:
Practical GUI toolkit?
Hi,
I'm just getting my head around Python, and have been building some stuff from tutorials, examples, etc. As my programs are getting more complex after a few weeks' tinkering, I'm getting overwhelmed by the pile of data my console is serving me (working on an app with lots of input...
Hello,
Can somebody please proof why it's a bad practice to use solution like this:
In django views in 98% cases you need to use
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
anyway in my project my every view has these imports and e...
I have written a python script to use gstreamer (pygst and gst modules) to calculate replaygain tags, and it was crashing inconsistently with various gobject errors. I found somewhere that you could fix this by putting the following boilerplate at the top of your script:
import gobject
gobject.threads_init()
I tried it, and it worked....
I'm new to GAE, and have not been able to figure out how to configure 'print' statements to the logging console rather than the browser. For example:
class Feed(webapp.RequestHandler):
def post(self):
feeditem = Feeditem()
feeditem.author = self.request.get('from')
feeditem.content = self.request.get('content...
I have a Python CGI script from which I am trying to call a Java program to perform a task. The Java program uses JExcelAPI. When I run the Python script from the browser, it fails with error messages that it can't find the class definitions for the classes from JExcelAPI. I suppose this happens because the Python CGI script is run under...
I would like to:
pylab.figure()
pylab.plot(x)
pylab.figure()
pylab.plot(y)
# ...
for i, figure in enumerate(pylab.MagicFunctionReturnsListOfAllFigures()):
figure.savefig('figure%d.png' % i)
What is the magic function that returns a list of current figures in pylab?
Websearch didn't help...
...
Using the code below leaves me with an open connection, how do I close?
import pyodbc
conn = pyodbc.connect('DRIVER=MySQL ODBC 5.1 driver;SERVER=localhost;DATABASE=spt;UID=who;PWD=testest')
csr = conn.cursor()
csr.close()
del csr
...
First of all, sorry if this question is a little vague and rambling! I'm ok with Python, but I've never done anything HTTP related before.
I'm trying to automate submitting a web form, and from reading some of this page I understand that I need to do a POST request. I also found a code snippet demonstrating the urllib module:
import u...
I followed the instructions in this answer about writing a Python script to be used as a service. I placed my looping code in def main().
I installed the service with python my_script.py install. I was able to Start and Stop the service through services.msc in Windows XP.
It's a logging program that is intended to write logs as long as...
Where is the documentation for Mark Hammond's pywin32 package?
Yes, the title says it all. I haven't found any documentation links in his home page or Sourceforge page.
...
Possible Duplicate:
Image comparison algorithm
So basically i need to write a program that checks whether 2 images are the same or not. Consider the following 2 images:
http://i221.photobucket.com/albums/dd298/ramdeen32/starry_night.jpg
http://i221.photobucket.com/albums/dd298/ramdeen32/starry_night2.jpg
Well they are both ...
I am using Avro 1.4.0 to read some data out of S3 via the Python avro bindings and the boto S3 library. When I open an avro.datafile.DataFileReader on the file like objects returned by boto it immediately fails when it tries to seek(). For now I am working around this by reading the S3 objects into temporary files.
I would like to be a...
For the tuple, t = ((1, 'a'),(2, 'b'))
dict(t) returns {1: 'a', 2: 'b'}
Is there a good way to get {'a': 1, 'b': 2} (keys and vals swapped)?
I'm wanting to be able to return 1 given 'a' or 2 given 'b', perhaps converting to a dict is not the best way.
...
I am using Python 2.6 and have the Facebook API installed as a python package (under /usr/lib64/python2.6/site-packages/facebook/...) which means, it is available with a plain import facebook or from facebook import ....
This works well, as long as there is no name clash. For example, in my project, I try to import the Facebook API in m...