python

Multiple <html><body> </html></body> in same file

I have a multiple html files in one file: <html> <body> </body> </html> <html> <body> </body> </html> <html> <body> </body> </html> and the result is that I get a messed up html file. How to correct this without removing tags from the rest. I am using python to generate the ...

How do I get tags/keywords from a webpage/feed?

I have to build a tag cloud out of a webpage/feed. Once you get the word frequency table of tags, it's easy to build the tagcloud. But my doubt is how do I retrieve the tags/keywords from the webpage/feed? This is what I'm doing now: Get the content -> strip HTML -> split them with \s\n\t(space,newline,tab) -> Keyword list But this d...

How do I interleave strings in Python?

How do I interleave strings in Python? Given s1 = 'abc' s2 = 'xyz' How do I get axbycz? ...

Starting multiple instances of a python script at once from linux command line

Hello, I'd like to start a piece of python script a thousand times! instead of trying to start them one-by-one how can I do that from linux command line? Right now, I am doing it like this: nohup python test.py & nohup python test.py & nohup python test.py & nohup python test.py & nohup python test.py & ... Thanks in advance. ...

Portable version of pyCrypto? - Python

Hi folks, does a portable version of pyCrypto exist? would one be easy to create? Help would be awesome! ...

determining if process has terminated successfully

Hi, I have some code to execute the unix shell command in background in python import subprocess process = subprocess.Popen('find / > tmp.txt &',shell=True) I need to capture the scenario where i come to know that process has finished successful completion . Please explain with sample code Tazim ...

Facebook Python-SDK VS. PyFacebook?

I'm starting to develop a facebook application using Django. I'm trying to choose the appropriate API wrapper for my application and I can't decide whether to use PyFacebook (very well documented but no official release) or the official Facebook Python SDK (which is surprisingly poorly documented). Are there any major differences betw...

Is it possible to use Python with php

I have a VPS Linux webserver with php installed. I want to code some search engine or data mining stuff in one application which i am thnking of building i python. I want to know that is it possible that i can use python and php together like calling function of python in php and vice versa As it is my VPS server i can install anythin...

closing a connection with twisted

Various connections - e.g. those created with twisted.web.client.getPage() seem to leak - they hang around indefinitely, since the OS time-out is measured in hours - if the server doesn't respond timely. And putting a time-out on the deferred you get back is deprecated. How can you track the requests you have open, and close them force...

Confused about using XPath or not.

Hi all. This follows my previous questions on using lxml and Python. I have a question, as to when I have a choice between using the methods provided by the lxml.etree and where I can make use of XPath, what should I use? For example, to get a list of all the X tags in a XML document, I could either iterate through it using the getit...

python string substitution

Is there a simple way of passing a list as the parameter to a string substitution in python ? Something like: w = ['a', 'b', 'c'] s = '%s\t%s\t%s\n' % w Something similar to the way dictionaries work in this case. ...

How to fetch multiple values of a class all at once without loop?

I know this is simple but I couldn' figure this out, I am fetching all the instances for a given linkname but I want to call all their values(rating2) to perform a calculation, what I realized though is in looping through I believe this is making an individual call each time, (its slow) it takes 2 seconds for only 100 instances of the L...

how can i pass a value of variable defined in python to a procedure in mysql as an input ?

I made a procedure in mysql and i call it using python but it take an input and i need to pass the value of a variable in python to it but the mysql doesn't understand that it is a variable because the variable is not defined in it's list of fields . for example for a code written in python : variable = "someValue" cursor.execute("call...

How to click and verify the existence of a pop up (alert)

I'm working with selenium. while trying to click a button it creates a pop up (alert) and doesn’t return a page object. Because of that I can’t use “click” alone as this method expects a page object and eventually fails because of a timeout. I can use the “chooseOkOnNextConfirmation()” but this will click the pop up and i also want to v...

how to connect my app python code to gui??

i had made a program for text to speech convertion in python..and now want to make an gui for it... i have installed wxpython..and have been trying few example available online to understand,but i am not exactly understanding it.. i basically want a frame and a text box to enter text and a button...on clicking the button it the text in...

Pros and cons for different configuration formats?

I've seen people using *.cfg (Python Buildout), *.xml (Gnome), *.json (Chrome extension), *.yaml (Google App Engine), *.ini and even *.py for app configuration files (like Django). My question is: why there are so many different configuration file formats? I can see an advantage from a xml vs json approach (much less verbose) or a Pytho...

How to set python enviroment variable on windows

I've downloaded python installer from http://www.python.org/ftp/python/3.1.2/ , this python-3.1.2.msi file, I need to execute some python files? how do I do that? like ex in php I'd do php filename.php from console, I do however have python command line but I don't know how to execute those files. So if I could set ENV variable to dire...

Cheat sheet documentation django python

Hi Is there any Cheat Sheet or Document where I can see all the build-in modules, functions, commands etc in Django and or Python and where I will get an overview of ALL possible elements I could use. I am sure this is would be a big file/image etc , but it would be very helpful to know what commands I could use. Any suggestions would ...

Writing a Python mail server with authentication

Hi, I'm trying to write a simple mail server using Python. I found smtpd that can be used as a simple smtp server, but I don't think it supports any form of authentication. For pop or imap, I haven't found anything at all yet. I do know Twisted has some support for both smtp and pop or imap, but I can't find any examples or tutorials...

Create an utf-8 csv file in Python.

I can't create an utf-8 csv file in Python. I'm trying to read it's docs, and in the examples section, it says: For all other encodings the following UnicodeReader and UnicodeWriter classes can be used. They take an additional encoding parameter in their constructor and make sure that the data passes the real reader or wri...