Is there a good way in Django to convert an entire model to a dictionary? I mean, like this:
class DictModel(models.Model):
key = models.CharField(20)
value = models.CharField(200)
DictModel.objects.all().to_dict()
... with the result being a dictionary with the key/value pairs made up of records in the Model? Has anyone els...
So I'm creating a django app that allows a user to add a new line of text to an existing group of text lines. However I don't want multiple users adding lines to the same group of text lines concurrently. So I created a BoolField isBeingEdited that is set to True once a user decides to append a specific group. Once the Bool is True no on...
I want to draw text on a tkinter canvas, within a previously drawn rectangle. I want to clip the text to be drawn entirely within the rectangle, hopefully by just specifying a maximum allowed width. Is there a straightforward way to do this in tkinter? If not, could I be using something else that would make it easier? Thanks
EDIT: "clip...
The following link outputs a different image every time you visit it:
http://www.biglickmedia.com/art/random/index.php
From a web browser, you can obviously right click it and save what you see. But if I were to visit this link from a command line (like through python+mechanize), how would I save the image that would output? So basical...
What's the best way to wait (without spinning) until something is available in either one of two (multiprocessing) Queues, where both reside on the same system?
...
Hi,
Basically, I would like to remove an item from a list whilst inside the foreach loop. I know that this is possible when using a for loop, but for other purposes, I would like to know if this is achievable using a foreach loop.
In python we can achieve this by doing the following:
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in a:
pr...
Problem: to get the command working here. My domain is http://cs.edu.com/user/share_dir, but I cannot get the command working by typing it to a browser:
http://cs.edu.com/user/share_dir:8000
Question: How can I get the command working?
...
Hello,
I have an application that consists of several .dlls, .libs, .pyd (python library), .exe, .class-es.
What is the best practice in the deployment process?
I plan to put .dlls - managed into GAC and unmanaged into WinSxS folder.
What should I do with .libs, .exe, .class and .pyd?
Is it ok to put it to
/ProgramFiles/Applicatio...
I have a file, for example "something.exe" and I want to find path to this file
How can I do this in python?
...
I'm getting an error when I try to run my script
Error:"IndentationError: unindent does not match any outer indentation"
Code snipet that throws the error:
def update():
try:
lines = open("vbvuln.txt", "r").readlines()
except(IOError):
print "[-] Error: Check your phpvuln.txt path and permissions"
...
Hello,
I am using python 2.5 on Windows. I wish to interact with a console process via Popen. I currently have this small snippit of code:
p = Popen( ["console_app.exe"], stdin=PIPE, stdout=PIPE )
# issue command 1...
p.stdin.write( 'command1\n' )
result1 = p.stdout.read() # <---- we never return here
# issue command 2...
p.stdin.write...
Suppose I have the following models:
class User(models.Model):
pass
class A(models.Model):
user = models.ForeignKey(User)
class B(models.Model):
a = models.ForeignKey(A)
That is, each user owns some objects of type A, and also some of type B. Now, I'm writing a generic interface that will allow the user to view any obj...
Hello,
let's say i have directory paths looking like this:
this/is/the/basedir/path/a/include
this/is/the/basedir/path/b/include
this/is/the/basedir/path/a
this/is/the/basedir/path/b
In Python, how can i split these paths up so they will look like this instead:
a/include
b/include
a
b
If i run os.path.split(path)[1] it will displa...
Hi folks,
I'm using django with apache and mod_wsgi and PostgreSQL (all on same host), and I need to handle a lot of simple dynamic page requests (hundreds per second). I faced with problem that the bottleneck is that a django don't have persistent database connection and reconnects on each requests (that takes near 5ms).
While doing a...
Problem: to run one.py from a server.
Error
When I try to do it in Mac, I get errors:
$python http://cs.edu.com/u/user/TEST/one.py ~
/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python: can't open file 'http://cs.edu.com/u/user/TEST/one.py': [Errno 2] No such file or dire...
Hi All.
While coding python I'm using only 2 spaces to indent, sure PEP-8 really recommend to have 4 spaces, but historically for me it's unusual.
So, can anyone convince me to use 4 spaces instead of 2? What pros and cons?
P.S. And finally, what's easy way to convert all existing codebase from 2 spaces to 4 spaces?
P.P.S. PEP-8 Al...
I'm trying to start perfmon and another program that have GUI's through a python script that uses a PKA ssh connection. Is it possible to do this? If so could anyone point me in the right direction?
...
Hi,
I'm looking for a documentation generator for python. I'm familiar with javadoc, and I tried Doxygen, but it seems quite unfit and counter-intuitive for python.
Any ideas?
Udi
EDIT
Apart from the excellent answers below, you can also consult wikipedia's exhaustive Comparison of documentation generators.
...
I'm trying to execute a series of commands using Pythons subprocess module, however I need to set shell variables with export before running them. Of course the shell doesn't seem to be persistent so when I run a command later those shell variables are lost.
Is there any way to go about this? I could create a /bin/sh process, but how wo...
I'm working with a Python development team who is experienced with programming in Python, but is just now trying to pick up TDD. Since I have some experience working with TDD myself, I've been asked to give a presentation on it. Mainly, I'm just wanting to see articles on this so that I can see how other people are teaching TDD and get...