I need to generate a list of insert statements (for postgresql) from html files, is there a library available for python to help me properly escape and quote the names/values? in PHP i use PDO to do the escaping and quoting, is there any equivalent library for python?
Edit: I need to generate a file with sql statements for execution lat...
Given a list of tuples, where each tuple represents a row in a table, e.g.
tab = [('a',1),('b',2)]
Is there an easy way to convert this to a record array? I tried
np.recarray(tab,dtype=[('name',str),('value',int)])
which doesn't seem to work.
...
Right now its a gmail box but sooner or later I want it to scale.
I want to sync a copy of a live personal mailbox (inbox and outbox) somewhere else, but I don't want to affect the unread state of any unread messages.
what type of access will make this easiest? I can't find any information if IMAP will affect the read state, but it ap...
How to extract substrings from a string at specified positions
For e.g.: ‘ABCDEFGHIJKLM’. I have To extract the substring from 3 to 6 and 8 to 10.
Required output: DEFG, IJK
Thanks in advance.
...
I'm having a trouble using SANE on Python to scan an image on a Kodak scanner.
The real headache comes to when I close the scanner device after getting the image, it just disappears from the SANE Devices lists until I restarted the Python interpreter, making impossible to scan another image.
It just acts like that with this scanner, I'...
I want to be able to join() the Queue class but timeouting after some time if the call hasn't returned yet.
What is the best way to do it? Is it possible to do it by subclassing queue\using metaclass?
...
Hi Stackoverflow!
I ran up against a few problems with Pylons/Formencode today when it came to validating multiple checkboxes. As a bit of background I have something like this in my Mako template:
<input type="checkbox" name="Project" value="1">Project 1</input>
<input type="checkbox" name="Project" value="2">Project 2</input>
<input ...
Hi.
I wasn't sure if there was any good way of doing this. But I thought I'd give stackoverflow a try :)
I have a list/array with integers, and a second array also with integers. I want to find the max value from the first list, but the value can not be in the second array.
Is there any "fancy" way in python to put this down to one exp...
The PEP 8 recommends that modules be imported at the beginning of programs.
Now, I feel that importing some of them at the beginning of the main program (i.e., after if __name__ == '__main__') makes sense. For instance, if the main program reads arguments from the command line, I tend to do import sys at the beginning of the main progr...
The following code works:
class Foo(tuple):
def __init__(self, b):
super(Foo, self).__init__(tuple(b))
if __name__ == '__main__':
print Foo([3, 4])
$ python play.py
play.py:4: DeprecationWarning: object.__init__() takes no parameters
super(Foo, self).__init__(tuple(b))
(3, 4)
But not the following:
class Foo(tup...
Hi,
I need a library (preferably written in Python) which is able to take a series of IP addresses (or geographic coordinates) and plots them on a World Map.
I already found this one, but it outputs data as a .svg file and it's simply unable to cope with large data sets.
Please note that I need something which can be downloaded and ...
Sometimes I need to parse string that is CSV, but I am having trouble whit quoted comas. As this code demonstrated. I am using python 2.4
import csv
for row in csv.reader(['one",f",two,three']):
print row
i get 4 elements ['one"', 'f"', 'two', 'three'] but I would like to get this ['one", f"', 'two', 'three'] or 3 elements even ...
Couldn't think of a better wording for the title.
See for instance the answer to http://stackoverflow.com/questions/1564501/add-timeout-argument-to-pythons-queue-join
The answer to that question uses an attribute of the Queue class called all_tasks_done (accidentally wrote join_with_timeout here in the original post).
However, in http:...
What am I missing:
In [66]: import numpy as np
In [67]: np.float(7.0 / 8)
Out[67]: 0.875 #OK
In [68]: np.float32(7.0 / 8)
Out[68]: 0.875 #OK
In [69]: np.float96(7.0 / 8)
Out[69]: -2.6815615859885194e+154 #WTF
In [70]: sys.version
Out[70]: '2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]'
Edit.
On cygwin the a...
Does anyone know why Python's list.append function is not called list.push given that there's already a list.pop that removes and returns the last element (that indexed at -1) and list.append semantic is consistent with that use?
...
If you take the following simple class:
class AltString:
def __init__(self, str = "", size = 0):
self._contents = str
self._size = size
self._list = [str]
def append(self, str):
self._list.append(str)
def output(self):
return "".join(self._list)
And I successfully invoke the class...
I have a large infrastructure that is written in Python 2.6, and I recently took a stab at porting to 3.1 (was much smoother than I expected) despite the lack of backwards compatibility.
I eventually want to integrate some of this Python code with a lot of Java based code that we have, and was thinking about giving Jython a try. However...
I'd like to be able to get a dictionary of all the parameters passed to a function.
def myfunc( param1, param2, param3 ):
print 'Param1=%(param1)s, Param2=%(param2)s Param3=%(param3)' % __method_param_dict__
So my question is does the dictionary method_param_dict exist, and if so what is it called.
Thanks
...
I have a list of floats. If I simply print it, it shows up like this:
[9.0, 0.052999999999999999, 0.032575399999999997, 0.010892799999999999, 0.055702500000000002, 0.079330300000000006]
I could use print "%.2f", but that would require a for loop to traverse the list, which I consider to be ugly. I believe that there must be a better s...
I've got validation working on client side using lxml, but I'm not quite sure how to get it work on google app engine, since it doesn't have the lxml package. I tried copying the whole lxml folder and place it in the root of my google application, but it seems like it cannot use it properly. I'm guessing it has to do with the compiled .s...