I have some models I'm working with in a new Django installation. Is it possible to change the fields without losing app data?
I tried changing the field and running python manage.py syncdb. There was no output from this command.
Renavigating to admin pages for editing the changed models caused TemplateSyntaxErrors as Django sought to ...
I am using this module to authenticate using pam:
http://code.google.com/p/web2py/source/browse/gluon/contrib/pam.py
I can call authenticate('username','password') and it returns True/ False. It works for any 'username' but 'root'. My guess is that there is a security restriction in PAM that does not allow to check for the root password...
I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython).
In particular, I am interested in getting "build" and "run" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about.
Also, can the "build" command be ...
Here are some models I am trying to load data for:
class School(models.Model):
name = models.CharField(max_length=200)
def __unicode__(self):
return self.name
class RequirementSet(models.Model):
offeringSchool = models.ForeignKey(School)
name = models.CharField(max_length=200)
def __unicode__(self):
...
i wrote this python code, which from wolfram alpha says that its supposed to return the factorial of any positive value (i probably messed up somewhere), integer or not:
from math import *
def double_factorial(n):
if int(n) == n:
n = int(n)
if [0,1].__contains__(n):
return 1
a = (n&1) + 2
...
I do understand that querying a non-existent key in a defaultdict the way I do will add items to the defaultdict. That is why it is fair to compare my 2nd code snippet to my first one in terms of performance.
import numpy as num
from collections import defaultdict
topKeys = range(16384)
keys = range(8192)
table = dict((k,defaultdict(i...
Sometimes the best way to debug something is to print some stuff to the page, and exit(), how can I do this in a Python/Django site?
e.g. in PHP:
echo $var;
exit();
Thanks
...
I have two versions of a piece of text and I want to produce an HTML view of its revision similar to what Google Docs or Stack Overflow displays. I need to do this in Python. I don't know what this technique is called but I assume that it has a name and hopefully there is a Python library that can do it.
Version 1:
William Henry "...
How can I convert xml to Python data structure using lxml?
I have searched high and low but can't find anything.
Input example
<ApplicationPack>
<name>Mozilla Firefox</name>
<shortname>firefox</shortname>
<description>Leading Open Source internet browser.</description>
<version>3.6.3-1</version>
<license name="Firefox EULA">...
I've been looking around for a way to anti-alias lines in OpenGL, but none of them seem to work... here's some example code:
import pyglet
from pyglet.gl import *
window = pyglet.window.Window(resizable=True...
I have a Python app which includes non-Python data files in some of its subpackages. I've been using the include_package_data option in my setup.py to include all these files automatically when making distributions. It works well.
Now I'm starting to use py2exe. I expected it to see that I have include_package_data=True and to include a...
Hello all.
I have been looking through Google and SO for something that could help me solve this but I have run into a block. I am a bit new to Python but I am looking for a way to run multiple apps that will continuously run in the background.
For example, I need 4 apps to start up with a param -appnum set to a different value. I woul...
I'm wanted to convert some of my python code to C++ for speed but it's not as easy as simply making a C++ function and making a few function calls. I have no idea how to get a C++ integer from a python integer object. I have an integer which is an attribute of an object that I want to use. I also have integers which are inside a list in ...
I'm trying my hand at building a MUD (multiplayer interactive-fiction game)
I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice.
Here's the problem as best I can explain it. When the player decides to perform a...
Python's list type has an index(x) method. It takes a single parameter x, and returns the (integer) index of the first item in the list that has the value x.
Basically, I need to invert the index(x) method. I need to get the index of the first value in a list that does NOT have the value x. I would probably be able to even just use a fu...
I have a dictionary of data, the key is the file name and the value is another dictionary of its attribute values. Now I'd like to pass this data structure to various functions, each of which runs some test on the attribute and returns True/False.
One approach would be to call each function one by one explicitly from the main code. Howe...
I'm trying to compile a Python extension (written in C) on a PPC mac (running
OS X 10.4, XCode 2.5), to run under Ren'Py on both PPC and i386 MacOS. The
PPC version works; the i386 version fails to load with
ImportError: dlopen(./fasttint_macos_i386.dylib, 2): Symbol not found: _PyType_GenericNew
Referenced from: /Applications/Games...
I made a python function to convert dictionaries to formatted strings. My goal was to have a function take a dictionary for input and turn it into a string that looked good. For example, something like "{'text':'Hello', 'blah':{'hi':'hello','hello':'hi'}}" would be turned into this:
text:
Hello
blah:
hi:
hello
hello...
Hey guys, I'm not trying to do anything malicious here, I just need to do some homework. I'm a fairly new programmer, I'm using python 3.0, and I having difficulty using recursion for problem-solving. I've been stuck on this question for quite a while. Here's the
Assignment:
Write a recursive method spam(url, n) that takes a url of a...
Howdy!
I am currently writing a small application with Python (3.1), and like a good little boy, I am doctesting as I go. However, I've come across a method that I can't seem to doctest. It contains an input(), an because of that, I'm not entirely sure what to place in the "expecting" portion of the doctest.
Example code to illustrate ...