In Python compiled regex patterns have a findall method that does the following:
Return all non-overlapping matches of
pattern in string, as a list of
strings. The string is scanned
left-to-right, and matches are
returned in the order found. If one or
more groups are present in the
pattern, return a list of groups; this
...
I have a list of objects (for the sake of example, let's say 5). I want a list of some of the possible permutations. Specifically, given that some pairs are not together, and some triples don't make sandwiches, how can I generate all other permutations? I realize that I generate all of them first and check that they work, but I think ...
I'm speaking of this module:
http://docs.python.org/library/operator.html
From the article:
The operator module exports a set of
functions implemented in C
corresponding to the intrinsic
operators of Python. For example,
operator.add(x, y) is equivalent to
the expression x+y. The function names
are those used for special...
Hi. I'm used to sampling C-based apps, which every few milliseconds sees what function stack is being called at that moment.
This allows me to see where most of the time is spent in an app so I can optimize it.
When using python, however, sample isn't so helpful, since it's sampling the C functions of the python interpreter, not the py...
I have two models, Room and Image. Image is a generic model that can tack onto any other model. I want to give users a form to upload an image when they post information about a room. I've written code that works, but I'm afraid I've done it the hard way, and specifically in a way that violates DRY.
Was hoping someone who's a little ...
A lot of modules I use import entire files into memory or trickle a file's contents in while they process it. I'm wondering if there's any way to track this sort of loading progress? Possibly a wrapper class that takes a callback?
...
I'm looking for a library, service, or code suggestions to turn spelled out numbers and amounts (eg. "thirty five dollars and fifteen cents", "one point five") into numerics ($35.15, 1.5) . Suggestions?
...
Hi.
Python 2.5.1
http://www.cgsecurity.org/wiki/After_Using_PhotoRec
I've just run PhotoRec and the code given as a way to sort file types into their own folder is coming back with this error. Any suggestions on how to alter? Thanks :
[EDIT2: Two points:
This question was voted down because it was a 'usage' of code, somehow not a p...
In Python we can "dir" a module, like this:
>>> import re
>>> dir(re)
And it lists all functions in the module. Is there a similar way to do this in Ruby?
...
Hi, I am looking for the python script used to automate the windows mobile device5 operations.If anyone know the solution,let me know.Thanks if any help provided to me.
...
Are there any standalone type conversion libraries?
I have a data storage system that only understands bytes/strings, but I can tag metadata such as the type to be converted to.
I could hack up some naive system of type converters, as every other application has done before me, or I could hopefully use a standalone library, except I ca...
I've got a CMS that takes some dynamic content and renders it using a standard template. However I am now using template tags in the dynamic content itself so I have to do a render_to_string and then pass the results of that as a context variable to render_to_response. This seems wasteful.
What's a better way to do this?
...
In Django how can i return the total number of items (count) that are related to another model, e.g the way stackoverflow does a list of questions then on the side it shows the count on the answers related to that question.
This is easy if i get the questionid, i can return all answers related to that question but when am displaying th...
I'm new to the MDX/OLAP and I'm wondering if there is any ORM similar like Django ORM for Python that would support OLAP.
I'm a Python/Django developer and if there would be something that would have some level of integration with Django I would be much interested in learning more about it.
...
scrollingwindow as main frame for the application is not supported yet for pythoncard. how can i add scrollbars to main frame(background)?
...
I'd like to write a Python script for Amarok in Linux to automatically copy the stackoverflow podcast to my player. When I plug in the player, it would mount the drive, copy any pending podcasts, and eject the player. How can I listen for the "plugged in" event? I have looked through hald but couldn't find a good example.
...
let's say I have a bi-dimensional array like that
numpy.array([[0,1,1.2,3],[1,5,3.2,4],[3,4,2.8,4], [2,6,2.3,5]])
I want to have an array formed eliminating whole rows based on uniqueness of values of last column, selecting the row to keep based on value of third column.
e.g. in this case i would like to keep only one of the rows with ...
I've recently started to learn python , and I reached the with statement . I've tried to use it with a class instance , but I think I'm doing something wrong . Here is the code :
from __future__ import with_statement
import pdb
class Geo:
def __init__(self,text):
self.text = text
def __enter__(self):
print "entering"
...
As the title suggests, I'm using Google App Engine and Django.
I have quite a bit of identical code across my templates and would like to reduce this by including template files. So, in my main application directory I have the python handler file, the main template, and the template I want to include in my main template.
I would have t...
I am from C background and I just started learning python...
while trying some programs, I got this doubt...
how python evaluates the expression 1+++2?
No matter how many number of '+' I put in between, it is printing 3 as the answer. Please can anyone explain this behavior
and for 1--2 it is printing 3 and for 1---2 it is printing ...