to do string substitutions in python, use the “re” module and the “sub” function:>>> import re…>>> test = “2545423/1-4242:0.3245″>>> test ; re.sub(”/\d-\d*:”,”:”,test) ‘2545423/1-4242:0.3245′ ‘2545423:0.3245′and, to match a group and then use it in the substitution, use parentheses and the \<number> …
Blogs / from the desk of stinkpot
from the desk of stinkpot
like adult diapers for my brain, this blog will prevent all those useful programming and computer tricks i've learned from leaking out of my head.
Reader Reviews
Welcome to the Technorati blog page for "from the desk of stinkpot"! This page features information about the blogs that are in Technorati's community. Are you a reader or a fan of this blog? Have something to say about this blog? Write a review or a comment about it! You can write a review that will appear right here and, if you choose, in your twitter stream as well.
Latest posts
View all »-
using python to do perl-like text manipulation
http://desk.stinkpot.org:8080/tricks/index.php/2009/04/... -
handle ps2pdf dependency errors with ghostscript
http://desk.stinkpot.org:8080/tricks/index.php/2009/04/...while trying to upgrade my packages, i got caught with the following error:Removing ghostscript … Purging font configuration of gs… No alternatives for ps2pdf. dpkg: error processing ghostscript (–remove): subprocess pre-removal script returned error exit status 1 Errors were encountered while …
-
wait for an executed subprocess to complete in python
http://desk.stinkpot.org:8080/tricks/index.php/2009/03/...if you call a shell process from python, your script will normally trundle along without pausing for that process to complete. if you’d like the process to finish before your script continues on, use the communicate method:proc = sub.Popen(my_job,stdout=sub.PIPE) stdout,stderr = proc.communicate()…
2 blog reactions
View all »What are reactions? (more)
Blog Reactions are the number of links to the blog's home page or its posts from other blogs in the Technorati index. A subset of blog reactions, Technorati Authority is the number of unique blogs linking to this blog over the last six months. The higher the number, the more Technorati Authority the blog has. To see reactions to specific posts, you can find them listed on Technorati post pages.


No reader reviews yet.
Add a reader review