I have two list like this:
list1 = [{'id':1, 'name':'foo', 'age':20}, {'id':2, 'name':'foo', 'age':20}]
list2 = [{'id':2, 'created':'2004-12-23'}, {'id':12, 'created':'2004-12-23'},
{'id':1, 'created':'2004-12-23'}]
list1 = [{'id':1, 'name':'foo', 'age':20, 'match':True},
{'id':2, 'name':'foo', 'age':20, 'match':Tr...
Hello,
I have a program that runs when the functions have not been defined. When I put code into a function it does not execute the code it contains. Does anyone know why? Some of the code is:
def new_directory():
if not os.path.exists(current_sandbox):
os.mkdir(current_sandbox)
Thanks
...
or a simple way to iterate over columnName, value pairs?
My version of sqlalchemy is 0.5.6
Here is the sample code where I tried using dict(row), but it throws exception , TypeError: 'User' object is not iterable
import sqlalchemy
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm impo...
hi there,
i m trying to make the result of a template tag dependent from another template tag. the use case is the following. i have a headers list which contains all the columns i want to show in a table + the column of the model they are showing +whether they are visible or not.
LIST_HEADERS = (
('Title', 'title', True),
('F...
Importing the standard "logging" module pollutes sys.modules with a bunch of dummy entries:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32
>>> import sys
>>> import logging
>>> sorted(x for x in sys.modules.keys() if 'log' in x)
['logging', 'logging.atexit', 'logging.cStringIO', 'logging.codecs',
...
I have a glade GUI and i'm using dome gtk.MessageDialog widgets created with pygtk for user interaction. My problem is that whenever I throw a dialog message on the screen, they show up all over the place. One might show up on the top right corner, the next on the bottom left, top left, mid left etc...
Is there a way to force these thin...
Is it possible to send a variable number of arguments to a javascript function, from an array?
my arr = ['a','b','c']
var func = function()
{
// debug
alert(arguments.length);
//
for(arg in arguments)
alert(arg);
}
func('a','b','c','d'); // prints 4 which is what I want, then 'a','b','c','d'
func(arr); // pri...
Basically I have a subpackage with the same name as a standard library package ("logging") and I'd like it to be able to absolute-import the standard one no matter how I run it, but this fails when I'm in the parent package.
It really looks like either a bug, or an undocumented behaviour of the new "absolute import" support (new as of P...
Some results file produced by Fortran programs report double precision numbers (in scientific notation) using the letter D instead of E, for instance:
1.2345D+02
# instead of
1.2345E+02
I need to process huge amounts of this data using Python, and I just realized it cannot read the numbers in the D notation, for instance:
>>> A = 1.0...
I want to get many pages from a website, like
curl "http://farmsubsidy.org/DE/browse?page=[0000-3603]" -o "de.#1"
but get the pages' data in python, not disk files.
Can someone please post pycurl code to do this,
or fast urllib2 (not one-at-a-time) if that's possible,
or else say "forget it, curl is faster and more robust" ? Thanks
...
Hi there!
I have a TG 1.0 application (not 1.1 -- I'm not sure I can convince the admin to upgrade) running. I have my own checkout of the project from cvs that I'm developing with, and it's come time to integrate xlwt (http://www.python-excel.org/) into the web app.
However, I don't have administrator access and it's not easy to get ...
I am adding date_added and date_modified fields to a bunch of common models in my current project. I am subclassing models.Model and adding the appropriate fields, but I want to add automated save behavior (i.e: evey time anyone calls MyModel.save(), the date_modified field gets updated. I see two approaches: overriding the save() method...
So I made this class that outputs '{0}' when x=0 or '{1}' for every other value of x.
class offset(str):
def __init__(self,x):
self.x=x
def__repr__(self):
return repr(str({int(bool(self.x))}))
def end(self,end_of_loop):
#ignore this def it works fine
if self.x==end_of_loop:
retur...
I can't seem to find a good way to serialize both Django Models and Python dictionaries together, its pretty common for me to return a json response that looks like
{
"modified":updated_object,
"success":true
... some additional data...
}
Its simple enough to use either simplejson to serialize a dict or Django's serializers.seri...
I am trying to do this:
{% for movie in movie_list | sort(movie.rating) %}
But that's not right...the documentation is vague...how do you do this in Jinja2?
...
Hello!
I'm trying to upload an image using normal form for normal admin for normal model with normal image field.
thumb = fields.ThumbnailField(upload_to=make_upload_path, sizes=settings.VIDEO_THUMB_SIZE, blank=True, null=True)
But I'm getting an error:
Upload a valid image. The file you uploaded was either not an image or a corrupt...
Hi, where can I find good templates for django-registration? I've found one, but the activation isn't work properly - when user click on activation link he gets:
Hello !
Check your e-mail to confirm registration. 7 days left.
Instead of ~"Activation succesfull/fail".
...
I love python and hate the pdb debugger.
For instance, if I have a program where stdout is redirected, my pdb prompts all go to the redirection, because the library was written to write to stdout.
Oftentimes this problem is subtle, causing me to think a program is hanging when it's really waiting for input.
How do people work around ...
python:
m=[[0]*3]*2
for i in range(3):
m[0][i]=1
print m
I expect that this code should print
[[1, 1, 1], [0, 0, 0]]
but it prints
[[1, 1, 1], [1, 1, 1]]
...
A simple python script needs to run on a windows server with no python installed.
I used py2exe, which generated a healthy dist subdirectory, with script.exe that runs fine on the local machine.
However, when I run it on the server (Windows Server 2003 R2), it produces this:
The system cannot execute the specified program.
and ERRORL...