I have those models
class A(models.Model):
name = CharField(max_length=255)
class B(models.Model):
name = CharField(max_length=255)
relation = ForeignKey(A)
And I can register like this:
admin.site.register(A)
admin.site.register(B)
In /admin/ page, I can see A and B registered.
and "Add B" admin page, will display a c...
I need to get a plot that fits the data automatically using matplotlib. This is the code I was given:
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
....
lines = LineCollection(mpl.line_holder, colors=mpl.colorholder , linestyle='solid')
plt.axes().add_collection(lines)
plt.axes().set_aspect('equal', '...
Hi all,
I am trying to colorize my output (from a scons based system). I am using the following code snippet:
default_colors = self.get_text_attr()
default_bg = default_colors & 0x0070
stdout_handle = -1
stdout_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
retval = SetConsoleTextAttribute(self.stdout_handle, ...
Say I have a list
food_list = ['apple', 'pear', 'tomato', 'bean', 'carrot', 'grape']
How would I print the list in rows containing 4 columns, so it would look like:
apple pear tomato bean
carrot grape
...
Is it possible to pickle (using cPickle) an enum that has been exposed with Boost.Python? I have successfully pickled other objects using the first method described here, but none of that seems to apply for an enum type, and the objects don't seem to be pickleable by default.
...
say i have an output of this, i think its a list
['', 'AB-a-b-c-d', 'BC-f-c-a-r', 'CD-i-s-r']
i want to make the following:
['',[AB,a,b,c,d],[BC,f,c,a,r],[CD,i,s,r]]
or
['',[AB,BC,CD],[a,b,c,d],[f,c,a,r],[i,s,r]]
...
I am trying to create an automated program in Python that deals with Flash. Right now I am using Python Mechanize, which is great for filling forms, but when it comes to flash I don't know what to do. Does anyone know how I can interact with flash forms (set and get variables, click buttons, etc.) via Python mechanize or some other pytho...
In my function I read user's data from session and store them in a dictionary. Next I'm sending it to 'register' function from registration.backend but the function somehow get's it empty and a KeyError is thrown. Where are my data gone ? The code from function calling 'register' function :
data = request.session['temp_data']
email = da...
How can I get a ° character into a string?
...
I am having an issue with Python throwing an AttributeError on accessing a variable.
The code is below, redacted for clarity.
class mycollection(object):
"""
Collection of stuff.
"""
#"compile-time" define class variables.
__slots__ = ["stuff_list"]
def __init__(self):
self.stuff_list = []
def add...
1.the atom is :
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<subtitle>A subtitle.</subtitle>
<link href="http://example.org/feed/" rel="self" />
<link href="http://example.org/" />
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
<update...
I'm using the code below to print out rows containing 4 columns. How would I append each value in the list to a HTML table that also contains rows with four columns?
random_list = ['car', 'plane', 'van', 'boat', 'ship', 'jet','shuttle']
for i in xrange(0, len(food_list), 4):
print '\t'.join(food_list[i:i+4])
...
I think this is a pretty basic question, but here it is anyway.
I need to write a python script that checks to make sure a process, say notepad.exe, is running. If the process is running, do nothing. If it is not, start it. How would this be done.
I am using Python 2.6 on Windows XP
...
i'd like to be able to access specific lines of a csv file through the csv reader. For example, the fourth line. Is there a way to do this with python's csv reader module?
...
Source
from copy import deepcopy
class Field(object):
def __init__(self):
self.errors = []
class BaseForm(object):
pass
class MetaForm(type):
def __new__(cls, name, bases, attrs):
attrs['fields'] = dict([(name, deepcopy(attrs.pop(name))) for name, obj in attrs.items() if isinstance(obj, Field)])
re...
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, calculate and update ...
The question is in the title.
...
I'm a Python newbie. I've read A Byte of Python, and read some texts from Learning Python. The problem is I can't write applications, solve problems, or do things with python.
How can I do these things? What examples should I start with and what books and references will help me learn these things?
...
Hi
Is it possible to set the cursor position in a Tkinter Text widget? I'm not finding anything terribly useful yet.
The best I've been able to do is emit a <Button-1> and <ButtonRelease-1> event at a certain x-y coordinate, but that is a pixel amount, not a letter amount.
Any help would be welcome,
Thanks
...
I have a small python cgi script that accepts an image upload from the user, converts in into a different format, and saves the new file in a temp location. I would like it to then automatically prompt the user to download the converted file. I have tried:
# image conversion stuff....
print "Content-Type: image/eps\n" #have also tried...