python

Extract IP address from an html string (python)

My Friends, I really want to extract a simple IP address from a string (actually an one-line html) using Python. But it turns out that 2 hours passed I still couldn't come up with a good solution. >>> s = "<html><head><title>Current IP Check</title></head><body>Current IP Address: 165.91.15.131</body></html>" -- '165.91.15.131' is w...

Reading lines including space

I want to read file including spaces in each lines My current code def data(): f = open("save.aln") for line in f.readlines(): print "</br>" print line I am using python and output embedded in html File to be read - http://pastebin.com/EaeKsyvg Thanks ...

Why program with php frameworks if it can be done better with rubi on rails, python or java?

Hi, We have discussion in my job place about question (We use 1 of the php frameworks): Why program with php frameworks big web application if it can be done better with rubi on rails, python or java? Please say our opinion thanks ...

List available languages for PyGTK UI strings

I'm cleaning up some localisation and translation settings in our PyGTK application. The app is only intended to be used under GNU/Linux systems. One of the features we want is for users to select the language used for the applications (some prefer their native language, some prefer English for consistency, some like French because it so...

list exported functions from dll with ctypes

Is there anyway to know which functions exported from the dll througth python foreign function library -ctypes- and if possible to know details about the exported functions throught ctypes. if yes could someone provide snippet of code ...

file layout and setuptools configuration for the python bit of a multi-language library

So we're writing a full-text search framework MongoDb. MongoDB is pretty much javascript-native, so we wrote the javascript library first, and it works. Now I'm trying to write a python framework for it, which will be partially in python, but partially use those same stored javascript functions - the javascript functions are an intrinsi...

How to parse strings representing xml.dom.minidom nodes in python?

I have a collection of nodes xml.dom.Node objects created using xml.dom.minidom. I store them (individually) in a database by converting them to a string using the toxml() method of a the Node object. The problem is that I'd sometimes like to be able to convert them back to the appropriate Node object using a parser of some kind. As far...

using dictionary to assign misspelled words to its line number

This is the code I have now from collections import defaultdict goodwords = set() with open("soccer.txt", "rt") as f: for word in f.readlines(): goodwords.add(word.strip()) badwords = defaultdict(list) with open("soccer.txt", "rt") as f: for line_no, line in enumerate(f): for word in line.split(): if...

Visual Python - Visualize graphs relating to a movement

Hello, everyone! I'm working with visual python on a project where I need to simulate a physical movement. I'd like to present, in a different window than the one the actual, 3D sim is running, two graphs, both related to the movement: How the velocity and angular velocity progress over time. How the movement and rotation progress ov...

Pretty-printing of numpy.array

Hello, I'm curious, whether there is any way to print formated numpy.arrays, e.g., in the way similar to this: x = 1.23456 print '%.3f' % x If I want to print the numpy.array of floats, it prints several decimals, often in 'scientific' format, which is rather hard to read even for low-dimensional arrays. However, numpy.array apparent...

python urllib post question

hello ALL im making some simple python post script but it not working well. there is 2 part to have to login. first login is using 'http://mybuddy.buddybuddy.co.kr/userinfo/UserInfo.asp' this one. and second login is using 'http://user.buddybuddy.co.kr/usercheck/UserCheckPWExec.asp' i can login first login page, but i couldn't login...

Django aggregation on a date range

Hi all, I have been lurking and learning in here for a while. Now i have a problem that somehow i cannot see an easy solution. In order to learn django i am bulding an app that basically keeps track of booked items. What I would like to do is to show how many days per month for a selected year one item has been booked. i have the follow...

File management

I am working on python and biopython right now. I have a file upload form and whatever file is uploaded suppose(abc.fasta) then i want to pass same name in execute (abc.fasta) function parameter and display function parameter (abc.aln). Right now i am changing file name manually, but i want to have it automatically. Workflow goes like t...

Bypassing import in Python so that I don't have to upload multiple libraries and classes?

For example, I have a few python scripts, that link together and some libraries for it that need to be imported. I'm trying to reduce it to only one script. So instead of: import library.py Can I just take the coding from library.py and put into the main script? ...

how to print the linenumber of incorrectwords located in a txt file ?

i have this piece of code which only prints the line number of the incorrect words. i want it to print the linenumbers of the incorrect words from the txt file. Am i able to modify this code to do that? # text1 is my incorrect words # words is my text file where my incorrect word are in from collections import defaultdict d = defaultd...

Django and Haystack search problem.

Hi there guys! I am running Python 2.6, the lastest haystack, django 1.2 beta and I have tried both Woosh and Xapian backends. The problem is that I cannot do a __lt or __gt filter on an integer field - when such is used,there are always none results found... My model: # -*- coding: utf-8 -*- from django.db import models from django...

Confused as to use a class or a function: Writing XML files using lxml and Python

Hi. I need to write XML files using lxml and Python. However, I can't figure out whether to use a class to do this or a function. The point being, this is the first time I am developing a proper software and deciding where and why to use a class still seems mysterious. I will illustrate my point. For example, consider the following f...

Making only a part of model field available in Django

Hello I have a such model: GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female') ) class Profile(models.Model): user = models.ForeignKey(User) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) class FrontPage(models.Model): female = models.ForeignKey(User,related_name="female") male = models.ForeignKey(User,re...

how to Parse a string of given format to build a binary decision tree,using python?

After a bit further analysis on my requirement.I gained some more clarity..Sorry for presenting an unclear question. I want to know how can we parse a string with braces of the form((Question)(Left_Node)(right_node)). The question for example wil be of the form if segment size < 1.5,then choose left node,else right.The question can be a...

Web framework recommendation for python (webservices, auth, cache, ...)

Hi all, Googling for the past week, but cannot finally decide which python web framework would be right for me. The web app I'm about to develop would be almost completely "pure" html with js (jQuery). Server side would have to do the following: authentication session management caching web services (almost all the on page data would ...