I am working with potentially huge XML files containing complex trace information from on of my projects.
I would like to build indexes for those XML files so that one can quickly find sub sections of the XML document without having to load it all into memory.
If I have created a "shelve" index that could contains information like "boo...
Is there a Pythonic 'standard' for how regular expressions should be used?
What I typically do is perform a bunch of re.compile statements at the top of my module and store the objects in global variables... then later on use them within my functions and classes.
I could define the regexs within the functions I would be using them, but...
Hi
I have a number of functions with a combination of positional and keyword arguments, and I would like to bind one of their arguments to a given value (which is known only after the function definition). Is there a general way of doing that?
My first attempt was:
def f(a,b,c): print a,b,c
def _bind(f, a): return lambda b,c: f(a,b,...
I am just a beginner in python. Recently i am learning to use dictionaries but my knowledge in it is still limited. I have this idea popping out from my head but i am not sure whether it is workable in python.
I have 3 document looks like this:
DOCNO= 5
nanofluids :0.6841
introduction:0.2525
module :0.0000
to :0.0000...
I'm using Django on GAE. When I say user = request.user, I believe it hits the datastore to fetch the User entity.
I would like to just get the key for the currently logged in user, because that will allow me to get the user-related data I need from the memcache.
...
I'm writing a script for exporting some data.
Some details about the environment:
The project is Django based
I'm using raw/custom SQL for the export
The database engine is MySQL.
The database and code are on the same box.-
Details about the SQL:
A bunch of inner joins
A bunch of columns selected, some with a basic multiplication ...
Using the json module in python 2.6, I'm experiencing some unexpected behavior when passing a function to object_hook. I'm attempting to turn a json object into a class defined in my code. This class requires that instances of a different class as arguments. Something like this:
class OuterClass:
def __init__(self, arg, *InnerClass_...
I'm trying to read through an xml feed I'm getting, but I can't access the specific elements. I'm using python, and the python documentation is really unclear about what I should use.
Here is the feed:
<title>More eagle</title>
<summary>http://www.181.fm/winamp.plsstation=181eagle&amp;style=&amp;description=The%20Eagle%20(Class...
I am asking because the way I have it right now seems really strange. Basically, I am saying, "If there is an exception thrown, do something. Else, do nothing." Here is some sample code:
try:
db.get(db.Key(uid))
except:
newUser = User(key_name=str(uid))
newUser.first_name = self.request.get("first")
n...
Hello All,
Running:
Windows Vista
Python 2.6
Matplotlib 0.99.3
The following script using draw() in matplotlib seems to work all right until almost anything momentarily interferes with the plot window.
import pylab as p
import time
try:
p.ion()
fig = p.figure()
subplt = fig.add_subplot(111, aspect='equal')
subplt.s...
I am having a bit of difficulty getting Env.js working with my Python application. The documentation on the website states:
develop bridges for running Envjs in Ruby, Python, and other host languages with the SpiderMonkey and V8 javascript engines
However, I have been unable to find any bridges to Python in either the main branch ...
hello all,
i am interested in a small python application, which can be downloaded here :
https://launchpad.net/treemap
if you run it, like this:
python treemap-basic.py examle-world-population.txt
it works just fine.
the problem is that even if i type a print command in the "treemap-basic.py" file :
print "Hello World !" @ treemap-ba...
I'd like to be able to have the operator of my class interact with regular types in a way that I define. Lets say, for example, I have:
class Mynum(object):
def __init__(self, x):
self.x = x
def __add__(self, other):
return self.x + other.x
a = Mynum(1)
b = Mynum(2)
print a+b
This works just fine, but now if I try to do:
...
Is it possible to give pyparsing a parsed list and have it return the original string?
...
I am trying to understand architecture of authlogic and repoze.what/who libraries but I could get the first level architectural definition. repoze packages seems to use the zope modules at some level..
Are there any equivalent or easier authentication framework like authlogic available in python? (I do not use Django.. I use Pylons)
A...
Hi,
Why am I getting this issue? and how do I resolve it?
UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 24: unexpected code byte
Thank you
...
Consider this:
>>> foo = {}
>>> foo[1] = 1.0
>>> foo[2] = foo[1]
>>> foo
{1: 0.0, 2: 0.0}
>>> foo[1] += 1.0
{1: 1.0, 2: 0.0}
This is what happens. However, what I want would be that the last line reads:
{1: 1.0, 2: 1.0}
Meaning that both refer to the same value, even when that value changes. I know that the above works the way it ...
In python, if you need a module from a different package you have to import it. Coming from a Java background, that makes sense.
import foo.bar
What doesn't make sense though, is why do I need to use the full name whenever I want to use bar? If I wanted to use the full name, why do I need to import? Doesn't using the full name immedia...
Hi,
I've created a pretty complex Google spreadsheet. I would like a user to be able to click a button or follow a link, and get a copy of this spreadsheet where they can fill in data. I would later check process this data manually.
Is there anyway I can do this via a complicated link, or some Javascript, or possibly even using a ser...
Hey everyone,
Is it possible to write a firewall in python? Say it would block all traffic?
Thanks!
Jake
...