python

Parsing html for domain links

I have a script that parses an html page for all the links within it. I am getting all of them fine, but I have a list of domains I want to compare it against. So a sample list contains list=['www.domain.com', 'sub.domain.com'] But I may have a list of links that look like http://domain.com http://sub.domain.com/some/other/page I c...

Downloading all ctrl alt del webcomics using terminal.

I've tried using the following commands to download the ctrl alt del comics. $ for filename in $(seq 20021023 20100503); do wget http://www.ctrlaltdel-online.com/comics/"$filename".jpg; done I get the following error code, "bash: syntax error near unexpected token 'do'" I've also tried using cURL, using this command, curl http://ctr...

How to split but ignore separators in quoted strings, in python?

I need to split a string like this, on semicolons. But I don't what to split on semicolons that are inside of a string (' or "). I'm not parsing a file; just a simple string with no line breaks. part 1;"this is ; part 2;";'this is ; part 3';part 4;this "is ; part" 5 Result should be: part 1 "this is ; part 2" 'this is ; part 3' part ...

Is there an easy way in Python to wait until certain condition is true?

I need to wait in a script until a certain number of conditions become true? I know I can roll my own eventing using condition variables and friends, but I don't want to go through all the trouble of implementing it, since some object property changes come from external thread in a wrapped C++ library (Boost.Python), so I can't just hij...

Creating a list in Python with multiple copies of a given object in a single line.

Suppose I have a given Object (a string "a", a number - let's say 0, or a list ['x','y'] ) I'd like to create list containing many copies of this object, but without using a for loop: L = ["a", "a", ... , "a", "a"] or L = [0, 0, ... , 0, 0] or L = [['x','y'],['x','y'], ... ,['x','y'],['x','y']] I'm especially interested in the th...

How to get data from a incoming email and then copy data to some directory

First of all, I have some time reading this page and I find very interesting, the content also has many questions and are very entertaining. My question is about handling my incoming mail server, no matter if you use PHP, Perl, or Python. I do not care, what if I want is the result which should be as close to: I send an email to update...

Quickbooks integration: IPP/IDS: can these by used for actual data exchange?

Poking around options for integrating an online app with Quickbooks, I've made a lot of headway with QBWC, but it's fairly ugly. From an end user perspective the usability of QBWC is pretty low. Intuit is now pushing Intuit Partner Platform (IPP) and Intuit Data Services (IDS). I can't quite figure out what these are about: Is IPP lim...

How to write full chat server / client using python 2.5

Hi All, I want to write server/client chat protocol using python-2.5 . I want to make protocol similar to yahoo messenger or google-talk. Please suggest me how to start. Thanks Reetesh Nigam ...

Google app engine: query that return entity ID using python

hi how do I return the entity ID using python in GAE? Assuming I have following class Names(db.Model): name = db.StringProperty() ...

Unable to import nltk in NetBeans

Hello all, I am trying to import NLTK in my python code and I get this error: Traceback (most recent call last): File "/home/afs/NetBeansProjects/NER/getNE_followers.py", line 7, in import nltk ImportError: No module named nltk I am using NetBeans: 6.7.1, Python 2.6 NLTK. My NLTK module is installed in /usr/local/lib/python2.6/d...

Have to find if some window name has some string on it with python

First of all, I get the name of the current window win32gui.GetWindowText(win32gui.GetForegroundWindow()) k, no problem with that... But now, how can I make an if with the result for having an specific string on it... For example, the result gave me C:/Python26/ How can I make an True of False for the result containing the word,...

How to create and restore a backup from SqlAlchemy?

I'm writing a Pylons app, and am trying to create a simple backup system where every table is serialized and tarred up into a single file for an administrator to download, and use to restore the app should something bad happen. I can serialize my table data just fine using the SqlAlchemy serializer, and I can deserialize it fine as well...

[genshi] Print string as HTML

Hello, I would like to know if is there any way to convert a plain unicode string to HTML in Genshi, so, for example, it renders newlines as <br/>. I want this to render some text entered in a textarea. Thanks in advance! ...

TurboGears 2.1 @expose renderer with custom mime type

We have a TurboGears 2.1 application where we have added several renderers, but I'm having trouble getting them to set the correct MIME type. In config/app_cfg.py we enable the renderers: class LITSAdminConfig(AppConfig): def setup_csv_renderer(self): self.render_functions.csv = render.render_csv def setup_pdf_renderer(...

How do I attach event bindings to items on a canvas using Tkinter?

If I'm using a canvas to display data and I want the user to be able to click on various items on the canvas in order to get more information or interact with it in some way, whats the best way of going about this? Searching online I can find information about how to bind events to tags but that seems to be more indirect then what I wa...

how to show all method in <class 'google.appengine.api.users.User'>

i want to see the all method in how to get it thanks ...

How to censor IP addresses in a file with Python?

Hello everyone. I have a log file containing some Whois entries with relative IP addresses which I want to censor like: 81.190.123.123 in 81.190.xxx.xxx. Is there a way to make such a conversion and rewrite the file contents without modifying the rest? Thank you for the help! ...

Create Django formset wihtout multiple queries

I need to display multiple forms (up to 10) of a model on a page. This is the code I use for to accomplish this. TheFormSet = formset_factory(SomeForm, extra=10) ... formset = TheFormSet(prefix='party') return render_to_response('template.html', { 'formset' : formset, }) The problem is, that it seems to me that Django queries...

Python: Huge file reading by using linecache Vs normal file access open()

Hi, I am in a situation where multiple threads reading the same huge file with mutliple file pointers to same file. The file will have atleast 1 million lines. Eachline's length varies from 500 characters to 1500 characters. There won't "write" operations on the file. Each thread will start reading the same file from different lines. Whi...

python dictionary conversion from string?

if I've string like "{ partner_name = test_partner}" OR " { partner_name : test_partner } its an example string will be very complex with several special characters included like =, [ , ] , { , } what will be the best way to convert it into a python object - so I can process it I tried with eval but it requires " ' " for string, but...