How can I write a program that will automatically generate an sample examination for example
The user will be prompted to supply four categories of questions to be included in the a 6 question exam from the following list: Loops,Functions,Decisions,Data Types,Built-in functions, Recursion, Algorithms, Top-down design,Objects.
I also ne...
Hello, trying to understand how custom admin commands work, I have my project named "mailing" and app inside named "msystem", I have written this retrieve.py to the mailing/msystem/management/commands/ folder and I have pasted an empty init.py both to the management and cpmmands folders.
from django.core.management.base import BaseComma...
Hi stack overflow, I have a problem with some numpy stuff. I need a numpy array to behave in an unusual manner by returning a slice as a view of the data I have sliced, not a copy. So heres an example of what I want to do:
Say we have a simple array like this:
a = array([1, 0, 0, 0])
I would like to update consecutive entries in the ...
Here are the best implementations I could find for lazy infinite sequences of Fibonacci numbers in both Clojure and Python:
Clojure:
(def fib-seq (lazy-cat [0 1]
(map + fib-seq (rest fib-seq))))
sample usage:
(take 5 fib-seq)
Python:
def fib():
a = b = 1
while True:
yield a
a,b = b,a+b
sample usage:
for i in fib():
i...
I'm writing an application to parse certain network packets. A packet field contains the protocol version number in an octet, so that 4 high bits are the 'major' and low 4 are the 'minor' version. Currently I am parsing them as follows, but am wondering if there is a prettier or more 'pythonic' way of doing it:
v = ord(data[17])
...
I am trying to model a VARBINARY MySQL field in Django v1.1.1. The binary field stores a hexadecimal representation of data (i.e. one would use INSERT INTO test(bin_val) VALUES X'4D7953514C')
Reading the Django documentation[1] I came up with this sollution:
class MyTest(models.Model):
bin_val = BinValField()
class BinValField(mod...
Sorry, perhaps I haven't described the problem well first time. All your answers are interesting, but most of them are almost full-featured web browsers, my task is much simpler.
I'm planning to write a GUI application using one of the available on linux GUI frameworks (I haven't yet chosen one). I shall use html in my application to re...
We've got a python library that we're developing. During development, I'd like to use some parts of that library in testing the newer versions of it. That is, use the stable code in order to test the development code. Is there any way of doing this in python?
Edit: To be more specific, we've got a library (LibA) that has many useful thi...
I need to convert paths in 8.3 convention to full path.
In Perl, I can use Win32::GetLongPathName() as pointed out in How do I get full Win32 path from 8.3 DOS path with Perl? But, I need to do it in Python.
...
hello,
I have snapshots of multiple webpages taken at 2 times. What is a reliable method to determine which webpages have been modified?
I can't rely on something like an RSS feed, and I need to ignore minor noise like date text.
Ideally I am looking for a Python solution, but an intuitive algorithm would also be great.
Thanks!
...
Hello!
I have a web server that is dynamically creating various reports in several formats (pdf and doc files). The files require a fair amount of CPU to generate, and it is fairly common to have situations where two people are creating the same report with the same input.
Inputs:
raw data input as a string (equations, numbers, and
l...
I am familiar with the input() function, to read a single variable from user input. Is there a similar easy way to read two variables?
I'm looking for the equivalent of:
scanf("%d%d", &i, &j); // accepts "10 20\n"
One way I am able to achieve this is to use raw_input() and then split what was entered. Is there a more elegant way?
T...
I am getting recarray from matplotlib.mlab.csv2rec function. My expectation was it would have 2 dimensions like 'x', but it has 1 dimension like 'y'. Is there any way to get x from y?
>>> import numpy as np
>>> from datetime import date
>>> x=np.array([(date(2000,1,1),0,1),
... (date(2000,1,1),1,1),
... (date(...
As I work on my first django powered site, I am constantly learning new things and making all sorts of changes and additions to my apps as I go. I try to follow DRY and pythonic principles and be smart in my coding but eventually I will have to take the site live and am certain that not long after I do, something new and exiting will co...
Why is PHP considered more scalable than python?
I've heard may times that one of the reasons PHP is "better" than python is that PHP is more easily scalable, and that Yahoo proves that(assumig Yahoo still uses PHP).
Whats the difference between PHP and Python when it comes to scalability?
-- edit --
well, i have no evidence, the que...
I'm writing a GAE app in Java and only using Python for the data
upload. I'm trying to import a CSV file that looks like this:
POSTAL_CODE_ID,PostalCode,City,Province,ProvinceCode,CityType,Latitude,Longitude
1,A0E2Z0,Monkstown,Newfoundland,NL,D,47.150300000000001,-55.299500000000002
I was able to import this file in my datastore if I ...
I'm looking at using CouchDB for one project and the GAE app engine datastore in the other. For relational stuff I tend to use postgres, although I much prefer an ORM.
Anyway, what use cases suit non relational datastores best?
...
What benefit or implications could we get with Python code like this:
class some_class(parent_class):
def doOp(self, x, y):
def add(x, y):
return x + y
return add(x, y)
I found this in an open-source project, doing something useful inside the nested function, but doing absolutely nothing outside it exce...
I'm looking for a way to prevent multiple hosts from issuing simultaneous commands to a Python XMLRPC listener. The listener is responsible for running scripts to perform tasks on that system that would fail if multiple users tried to issue these commands at the same time. Is there a way I can block all incoming requests until the single...
I am a Python and QT newbie. I am trying to do a little app with PyQT4 in order to supervise a home MySQL server of mine, so my first idea was to do the classic SHOW PROCESSLIST, parse it, and show in a pretty UI. Nothing big, really.
But for some reason, the QtSql module doesn't return anything when doing this query, although it works ...