Suppose I am building a composite set of types:
def subordinate_type(params):
#Dink with stuff
a = type(myname, (), dict_of_fields)
return a()
def toplevel(params)
lots_of_types = dict(keys, values)
myawesomedynamictype = type(toplevelname, (), lots_of_types)
#Now I want to edit some of the values in myawesomedyna...
c2=[]
row1=[1,22,53]
row2=[14,25,46]
row3=[7,8,9]
c2.append(row2)
c2.append(row1)
c2.append(row3)
c2 is now:
[[14, 25, 46], [1, 22, 53], [7, 8, 9]]
how do i sort c2 in such a way that for example:
for row in c2:
sort on row[2]
the result would be:
[[7,8,9],[14,25,46],[1,22,53]]
the other question is how do i first sort by ro...
I'm new to python and django but wanted to start following some tutorials. I installed python, then django, and then the pydev plugin for eclipse. I created a new django project and tried running it. In eclipse I set up a run configuration for manage.py with argument runserver and it said "Validating Models" but never said anything el...
Example:
I have the literals "alpha", "beta", "gamma". How do I make pyparsing parse the following inputs:
alpha
alpha|beta
beta|alpha|gamma
The given input can be constructed by using one or more non-repeating literals from a given set, separated by "|". Advice on setting up pyparsing will be appreciated.
...
I have a table which is being mapped with SqlAlchemy. In that table is a UUID column. When I try to query that table, I get the uuid in bytes_le format. Is there some way I can tell the mapper to return a clean string representation instead? Code for the mapper is:
Practice = Table('Practice',metadata,
schema='pulse...
I have a string that contains html markup like links, bold text, etc.
I want to strip all the tags so I just have the raw text.
What's the best way to do this? regex?
...
c1 is a list of lists like this:
c1=[[1,2,3],[1,2,6],[7,8,6]]
for row in c1:
i want to keep track of whether there is a change in row[0]
for example:
in [1, 2, 3] and [1, 2, 6] there is no change in row[0]
however in [1, 2, 6] and [ 7, 8, 6] there is a change in row[0]
how do i catch this change?
also i would like to know which r...
I got this after installing the tagging application. I've installed it via settings.py as well as placing it on the import path so I think I've done everything right there. This is what turns up. You can see my error log here. I've run syncdb, so my database should be synced up.
...
Looking for a python library that handles minifying and merging JS\CSS files together...
...
For the past 10 hours I've been trying to accomplish this:
Translation of my blocking httpclient using standard lib...
Into a twisted nonblocking/async version of it.
10 hours later... scoring through their APIs-- it appears no one has EVER needed to do be able to do that. Nice framework, but seems ...a bit overwhelming to just set a ...
i am using this:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html
i have an list a that i want to use like this:
numpy.histogram(a,bins=[0.1,0.2,0.3,0.4...6], range=[0:6])
how do i include a set of bins 0.1 through 6 in 0.1 intervals?
how do i specify a range of 0 through 6?
...
I want to
call shell commands (for example 'sleep' below) in parallel,
report on their individual starts and completions and
be able to kill them with 'kill -9 parent_process_pid'.
There is already a lot written on these kinds of things already but I feel like I haven't quite found the elegant pythonic solution I'm looking for. I'...
I created a function to read in a csv file and then write some of the data from the csv file into another file. I had to manipulate some of the data in the original csv file before I write it. I will probably have to do that manipulation a lot during the next couple months so I wrote another function to just do that manipulation, but I ...
Hi,
The code is in python.
Please find below the piece of code that I use to tokenize a string.
strList = list(token[STRING] for token in generate_tokens(StringIO(line).readline) if token[STRING])
I get an error that reads like:-
raise TokenError, ("EOF in multi-line statement", (lnum, 0))
tokenize.TokenError: ('EOF in multi-li...
Hi all,
I am just getting to know numpy, and I am impressed by its claims of C-like efficiency with memory access in its ndarrays. I wanted to see the differences between these and pythonic lists for myself, so I ran a quick timing test, performing a few of the same simple tasks with numpy without it. Numpy outclassed regular lists by a...
Is it just me or is having to run multiple instances of a web server to scale a hack?
Am I wrong in this?
Clarification
I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
...
Hi,
I was wondering and also try to do it, how to lock and suspend computer using dbus interface. I am able to suspend system using org.freedesktop.UPower with method Suspend(). I also am able to lock system using org.gnome.ScreenSaver with method Lock(). But how to do it at the same time?
Is it good way to use signal Suspend ? or the...
Hey there,
I need to know how to perform the procedure, you already have read in the title.
You'll upload an image (e.g. a piece of text, an article) and on server-side the text will be recognized via OCR and stored into a database.
Which would be the best programming language for it? It should be a browser application.
I found the oc...
(This question was reworded; please, give it a second chance before deleting it again!)
It would be nice if there existed a program that automatically transforms Perl code to Python code, making the resultant Python program as readable and maintainable as the original one, let alone working the same way.
The most obvious solution would...
this:
numpy.histogram([1,3,2,3,1,1,1,1,2,3,2,5,6,6],bins=numpy.arange(0,7,1))
yields:
(array([0, 5, 3, 3, 0, 3]), array([0, 1, 2, 3, 4, 5, 6]))
why does it count three 6's? there are only 2!
...