Hello,
I want to strip double quotes from
string = '"" " " ""\\1" " "" ""'
to become
string = '" " " ""\\1" " "" "'
I try to use rstrip, lstrip and strip('[^\"]|[\"$]') but it not work
How can I do?
sorry for my english.
Thank for help me.
...
I am using Python to parse entries from a log file, and display the entry contents using Tkinter and so far it's been excellent. The output is a grid of label widgets, but sometimes there are more rows than can be displayed on the screen. I'd like to add a scrollbar, which looks like it should be very easy, but I can't figure it out.
Th...
Using Perforce, I'd like to be able to reject submits which contain files with Windows line endings (\r\n IIRC, maybe just \r anywhere as really we only want files with Unix line endings).
Rather than dos2unix incoming files or similar, to help track down instances where users attempt to submit files with Windows line endings, I'd like ...
In python after imports, one can see the file, that has been loaded/where the module comes from.
>>> import os
>>> os.__file__
'/Users/tm/lib/python2.6/os.pyc'
What would be the equivalent in ruby?
>> require 'xmlrpc/client'
=> true
>> ...
...
When I'm running Jinja2 in Google App Engine, I get useless debugging information. I gather this is because of this item in the FAQ:
My tracebacks look weird. What’s happening?
If the speedups module is not compiled and you are using a Python installation without ctypes (Python 2.4 without ctypes, Jython or Google’s AppEngine) J...
I need to extract certain data from a file, but this file is formatted to be read by humans, and is therefore irregular. First off there is a large amount of text before any of the data actually begins:
DL_POLY Version 2.20
Running on 10 nodes
****** DLPOLY: LiN...
Hi i want to store null value in a column.The column is nullable.The column value is not null always it depends on certain conditions.I dont want to write two queries in this case.I have tried None,null both but it gives me error saying worng type for double precision
...
I was reading how Clojure is 'cool' because of its syntax + it runs on the JVM so it is multithreaded etc. etc.
Are languages like ruby and python single threaded in nature then? (when running as a web app).
What are the underlying differences between python/ruby and say java running on tomcat?
Doesn't the web server have a pool of th...
The program I've written stores a large amount of data in dictionaries. Specifically, I'm creating 1588 instances of a class, each of which contains 15 dictionaries with 1500 float to float mappings. This process has been using up the 2GB of memory on my laptop pretty quickly (I start writing to swap at about the 1000th instance of the c...
It's been said in a couple places (here and here) that Python's emphasis on "it's easier to ask for forgiveness than permission" (EAFP) should be tempered with the idea that exceptions should only be called in truly exceptional cases. Consider the following, in which we're popping and pushing on a priority queue until only one element is...
Hello all. I have a cgi python program which runs an os.system command and this command is printing output and causing havoc. How do I get python to run the os.system command and have that command print to the webpage it is being run on?
...
I need to generate a multipart/mime message to send as a response to a HTTP request but am hitting either a bug or limitation in the Python email.* package.
The problem is that using Python 2.6, the message.as_string() call below generates a string with \n rather that CRLF as the line endings:
message = MIMEMultipart()
for image in ima...
I have a list of dictionaries that looks something like this:
toCSV = [{'name':'bob','age':25,'weight':200},{'name':'jim','age':31,'weight':180}]
What should I do to convert this to a csv file that looks something like this:
name,age,weight
bob,25,200
jim,31,180
...
I'm using rpy2 to do data analysis and plotting in python. It works fine except for the fact that when I draw a plot, it's window hangs around until the program terminates. Is there a way to clear the plot during runtime? Additionally, If I ever resize the window, the plot disappears, but the window remains. When using R interactively, r...
Using this code
import re
file = open('FilePath/OUTPUT.01')
lines = file.read()
file.close()
for match in re.finditer(r"(?m)^\s*-+\s+\S+\s+(\S+)", lines):
eng = match.group(1)
open('Tmp.txt', 'w').writelines(eng)
print match.group(1)
I get a column of data that looks like this:
-1.1266E+05
-1.1265E+05
-1.1265E+05
-1.1265E+...
I want to use a custom base controller for my wep application that has a User object as a property, and a boolean IsLoggedIn property.
In the constructor of the base controller (or whatever event I need to do this in??) I want to look for a session cookie, if present, load the user and set the User object and set the IsLoggedIn property...
So redhat uses python 2.4 and I need to upgrade to python 2.6 (so I did an altinstall) does anybody know how to install mod_python? (I am installing from source.) This is what I ran:
./configure --with-apxs=/usr/sbin/apxs
./configure --with-python=/usr/local/bin/python2.6
make
make install
But according to a stack trace I get mod_pyth...
Example;
X=This
Y=That
not matching;
ThisWordShouldNotMatchThat
ThisWordShouldNotMatch
WordShouldNotMatch
matching;
AWordShouldMatchThat
I tried (?<!...) but seems not to be easy :)
...
I'm using Plone with Python scripts, I understand the scripts are restricted in Plone and I also understand that I need to create python scripts in the Extensions folder for a fully functional script.
But how do I send information between the two scripts? For example script1.py is located in the ZMI and has a directory which is a URL, ...
Hey,
I am a newcomer to the Python and Twisted game so excuse the ignorance I will likely be asking this question with. As a sort of first program, I am trying to write a basic HTTP server using twisted.web.sever which would simply print to screen the HTTP request, and then print to screen the HTTP response. I am trying to print the ent...