In python, I've got a string like
ABC(a =2,bc=2, asdf_3 = None)
By using regular expression, I want to make it like
ABC(a =2,bc=2)
I want to remove the parameter that named 'asdf_3', that's it!
Update: The parameters can be a lot, only the asdf_3 is same in all cases, the order is usually the last one.
...
I am using google appening, it's CGI environment. I want block some request, I want response nothing even no http status code. Alternative, I want just close the connection. Can I do this?
update:
I have decide to use what pyfunc said, use 204 status, but how can I do this at GAE CGI environment without any webframework.
update 2:
T...
I'm looking for an alternative library for the app engine datastore that will do nearest-n or boxed geo-queries, currently i'm using GeoModel 0.2 and it runs quite slow ( > 1.5s in some cases). Does anyone have any suggestions?
Thanks!
...
First of all, I am not a veteran programmer i any language. But I've been tinkering with python pretty substantially the last couple of months so I wouldn't consider my self completely green either.
Some keywords for you:
- Windows
- Python 2.6
- Pygame, CGKit
Okay, so I've got the CGKit module, which contains a WinTab wrapper for capt...
I'm currently running into a bit of a problem. I'm trying to write a program that will highlight occurrences of a word or phrase inside of another string, but only if the string it's being matched to is exactly the same. The part I'm running into troubles with is identifying whether or not the subphrase I'm matching the phrase with is co...
Im new to python and regular expressions. Im searching a file line by line for the occurrence of ##random_string##, and i want to be able to capture the random_string in-between the ##s.
Ive tried both patterns but no luck =/
pattern1=r'[##]()[##]'
pattern2=r'\#{2}()\#{2}'
prog=re.compile(pattern1)
result=prog1.search(line)
if result:...
Hi all,
I am trying to plot data that I receive over a socket. I am using "Matplotlib" as the plotting library and "cPickle" to serialize python objects.
When I run my code, plot window opens and hangs up. I have tried a couple of ways to get around it, but no help
Don't know if this might help, but...I am using "Python 2.7 - 32 bit" on ...
I want to do something like
for field in field_list:
my_table.field = new_value
Couldn't find any documentation on how to do the above with a variable.
...
I want to create an associative array with values read from a file. My code looks something like this, but its giving me an error saying i can't the indicies must be ints.
Thanks =]
for line in open(file):
x=prog.match(line)
myarray[x.group(1)]=[x.group(2)]
...
So I'm writing a basic feed aggregator/popurls clone site in Django and having trouble getting the feeds to update.
For each feed source, I have a separate app to parse and return the requested info, for the sake of simplicity let's say it's just getting the feed title. eg:
#feed source xyz views.py
from django.http import HttpResponse...
C++ is fast. Qt is fast. Python interpreter startup is relatively fast (2-3 seconds on my computer). PyQt is thin wrapper around Qt. Why then PyQt app startup (about 80 lines, even in .pyc form) is so slow (6-12 seconds)? I'm interested in reasons for this and, most importantly, ways to improve this situation.
...
I'm trying to check if a string is a number, so the regex "\d+" seemed good. However that regex also fits "78.46.92.168:8000" for some reason, which I do not want, a little bit of code:
class Foo():
_rex = re.compile("\d+")
def bar(self, string):
m = _rex.match(string)
if m != None:
doStuff()
And...
I've got a Debian 5 (lenny) setup with Python 2.6 built from source (2.6 isn't available through APT nor backports for some reason) and it has the PIL library installed.
During installation it passes telling me I have PNG/ZIP support, which is what i need, but when I either try to run the python script (which works on my windows machine...
I'm trying to create a QSpinBox that accepts all numbers, but I'm having some trouble with hte maximums
sbox = QSpinBox(self)
sbox.setRange(-sys.maxint/88-1, sys.maxint/86)
sbox.setValue(int(setting.value))
I wanted to just use sbox.setRange(-sys.maxint-1, sys.maxint) but then I couldn't enter anything, if I increase the range any ...
Is there an incarnation or fork of Python that formats blocks using punctuation instead of whitespace?
There seem to be quite a few branches of Python, such as JPython, IronPython, etc, so just wondered if optional whitespace indentation had been evolved into one of those variants.
I could potentially be interested in learning Python b...
I'm writing a script that will print a random line of text from a file into an XCHAT channel. So far it works fine, but I want to add one last bit of functionality.
I have logs with, for example, "Oct 23 12:07:59 (nickname> " appearing before every line of text. I just want to print the parts of the lines that follow the "(nickname>...
Suppose a user creates his account in a website so i would like to use django signals to notify the system admins that a new user has been created.
I really dont know how to do this with Django signals
Thanks in advance
...
Im trying to add elements to a dict list (associative array), but every time it loops, the array overwrites the previous element. So i just end up with an array of size 1 with the last element read. I verified that the keys ARE changing every time.
array=[]
for line in open(file):
result=prog.match(line)
array={result.group(1) : res...
Hi,
I have written some code which sends queries to google and returns the query results. Apparently the contents which are retrieved are in unicode format, so when I put them in a list for example and print this list (the whole list together and not member by member) an annoying extra 'u' is always behind all of the members in this list...
Basically I have two problems:
My newly coded module is not showing into module list , so I am unable to install.
I want to debug my module before installation , is there any way through i can do that
...