I have a form that looks similar to the following (simplified for brevity):
PRICING_PATTERN = r'(?:^\$?(?P<flat_price>\d+|\d?\.\d\d)$)|(?:^(?P<percent_off>\d+)\s*\%\s*off$)'
class ItemForm(forms.Form):
pricing = forms.RegexField(
label='Pricing',
regex=PRICING_PATTERN
)
pricing_type = forms.CharField(
...
I heard that B-Tree datbases are faster than Hash tables, so I thought of using a B-Tree Db for my project. Is there any existing framework in python which allows us to use such Data structure or will I have to code from scratch?
...
I am making a simple pie chart in reportlab. I can not find in the docs how to change each individual pies fill color.
pie_chart = Drawing(200, 200)
pc = Pie()
pc.x = 65
pc.y = 15
pc.width = 150
pc.height = 150
pc.data = [65,13,12,9,1]
pc.labels = ['Name','Another','Yet Another','Test','Stack']
pc.slices[1]. // This is where I need t...
I would like to write a context_processor, something like this:
settings.py:
MEDIA_URLS = ('cname2.example.com/media', 'cname3.example.com/media',)
TEMPLATE_CONTEXT_PROCESSORS = (
"util.context_processors.media",
)
util/context_processors.py
from random import choice
from django.conf import settings
def media(request):
"""
...
I have code for a Range class like this:
class Range:
def __init__(self, start, end):
self.setStart(start)
self.setEnd(end)
def getStart(self):
return self.start
def setStart(self, s):
self.start = s
def getEnd(self):
return self.end
def setEnd(self, e):
self.end = e
def getLength(se...
Hi
I've been looking high and low for a solution to this simple problem but I can't find it anywhere! There are a loads of posts detailing semilog / loglog plotting of data in 2D e.g. plt.setxscale('log') however I'm interested in using log scales on a 3d plot(mplot3d).
I don't have the exact code to hand and so can't post it here, how...
I'm a C# dev moving into some Python stuff, so I don't know what I'm doing just yet. I've read that you don't really need Dependency Injection with Python. I've been told you can instantiate objects in your code and have them run the way you want, however, you can point methods on those objects to my own stubs defined in my tests - supp...
I try to make two servers in a file, but they are fighting each other visibly
have anyone an idea to make them peace ?
here is my code :
# -*- coding: utf-8 -*-
import socket
import sys
import re
import base64
import binascii
import time
import zlib
import sys
import StringIO
import contextlib
import smtplib
from threading import Threa...
I'm using the fantastic python-sdk wrapper for the facebook graph api in python.
If I want to get the information on a friend's wall:
result = graph.get_connections( friendUID , "feed")
It returns a bunch of wall posts and a pair of URLs to access next/previous posts in
result["data"]["paging"]
It looks like
{u'next': u'https://grap...
The following python code describes exactly what I want to achieve for a sequence of arbitrary size (population):
import random
fixed_seed = 1 #generate the same sequence every time with a fixed seed
population = 1000
sample_count = 5 #demonstration number
num_retries = 3 #just enough to show the repeatable behaviour
for trynum in xran...
Hi, guys. I have seen some CLI questions here, but I still want to ask this question for more detailed answers.
I have already developed class1.py, class2.py, etc. with functions implemented inside each class. e.g. Operator.py has add, minus,time, devide functions. how can I build a command line interface for these classes?
also for ...
I have an idea for a simple web application and I've heard a lot about Ruby, Ruby on Rails, Python, PHP, etc.
But what language do you think is better to have working prototypes and get the application running online really quick?
NOTE: This is not a question about the language's performance, I am just trying to find the best language...
Hi, everyone.
Let's say there is a server on the internet that one can send a piece of code to for evaluation. At some point server takes all code that has been submitted, and starts running and evaluating it. However, at some point it will definitely bump into "os.system('rm -rf *')" sent by some evil programmer. Apart from "rm -rf" yo...
I'm a computer science teacher trying to create a little gradebook for myself using NumPy. But I think it would make my code easier to write if I could create an ndarray that uses field names for both the rows and columns. Here's what I've got so far:
import numpy as np
num_stud = 23
num_assign = 2
grades = np.zeros(num_stud, dtype=[(...
Hi
How do I display (turn on) minor ticks on a 3D surface plot using mplot3d / axes3d graph?
I can define the major tickmark locations using:
ax.w_zaxis.set_major_locator(MultipleLocator(10))
Similarly, I'm guessing I can define the the minor ticks using:
ax.w_zaxis.set_minor_locator(MultipleLocator(2))
This appears to define the m...
I'm writing a Django-based webapp that imports a Cocoa framework via PyObjC. The Cocoa framework has NSLog() littered all through it and while I can see them when running the Django server in non-daemon mode, as soon as I go to daemon I simply lose all this useful NSLog() output.
Is there any easy way to get NSLog stuff to bubble up in...
Howdy,
I am trying to figure out how to use proxy classes in Django. I want to receive a queryset where each object belongs to a proxy class of a common super class so that I can run custom sub-classed methods with the same name and my controller logic doesn't need to know or care about which kind of Proxy model it is working with. One ...
This is the code which i played, but each time i make a mistake i can't relaunch it.
It says to me that the port / socket is already used
That's the first question
The second one is in my MyTCPHandler how can i kno the port used ?
here is my code :
# MetaProject v 0.2
# -*- coding: utf-8 -*-
"""
Thanks to :
People from irc :
Flox,Luyt
...
hello All.
i have some problem to extract some data from html source.
following is sniffit of my html source code, and i want to extract string value in every
following
<td class="gamedate">10/12 00:59</b></td>
<td class="gametype">오버언더</b></td>
<td class="legue"><nobr style="width:100%;overflow:hidden;letter-spacing:-1;font-size...
Ok I have been writing a proxy to take http GET requests and translate them into HTTP POST requests (because a lot of media players for python only support GET). So I know am working on caching those results that way I only download a url once, I moved a lot of code from the super class to the sub class and changed it so that I could sen...