Re: [Tutor] Titles from a web page

2011-05-04 Thread Michiel Overtoom
On May 5, 2011, at 07:16, James Mills wrote: > On Thu, May 5, 2011 at 1:52 PM, Modulok wrote: >> You might look into the third party module, 'BeautifulSoup'. It's designed to >> help you interrogate markup (even poor markup), extracting nuggets of data >> based >> on various criteria. > > lxml

Re: [Tutor] Titles from a web page

2011-05-04 Thread James Mills
On Thu, May 5, 2011 at 1:52 PM, Modulok wrote: > You might look into the third party module, 'BeautifulSoup'. It's designed to > help you interrogate markup (even poor markup), extracting nuggets of data > based > on various criteria. lxml is also work looking into which provides similar functio

Re: [Tutor] Titles from a web page

2011-05-04 Thread Modulok
You might look into the third party module, 'BeautifulSoup'. It's designed to help you interrogate markup (even poor markup), extracting nuggets of data based on various criteria. -Modulok- On 5/4/11, louis leichtnam wrote: > Hello Everyone, > > I'm trying to write a program that looks in a webp

[Tutor] Titles from a web page

2011-05-04 Thread louis leichtnam
Hello Everyone, I'm trying to write a program that looks in a webpage in find the titles of a subsection of the page: For example you have the list of the title of stories in a newspaper under the section "World" and you you click on it you have the entire story. I want a program that print the

Re: [Tutor] Pictures

2011-05-04 Thread louis leichtnam
Hello, I tried it and it works, though if I change the web site from http://finance.blog.lemonde.fr to http://www. ...something else it doesn't work. DO I have to change the '([\S]+)' in x=re.findall(r" > Observing the page source i think : > > page=urllib.urlopen('http://finance.blog.lemon

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread ALAN GAULD
CC'd to list > Thanks for your suggestions. I now see I was using far too much unnecessary > code plus data structures (lists) that were useless. I modified the entire > program to the following lines based on suggestions from yourself and > other people on the mailing list: > import os, st

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Alan Gauld
"Jeff Peery" wrote Import sting Its lower case import and I've no idea what sting is! :-) If its meant to be string you don't need it. delimiter = ‘.’ f = open('words.txt', "r") lines = f.readlines() for line in lines: line_items = string.split(line,delimiter) You don't need th

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread Alan Gauld
"Spyros Charonis" wrote motif_file = open('myfolder/pythonfiles/final motifs_11SGLOBULIN', 'r') align_file = open('myfolder/pythonfiles/11sglobulin.seqs', 'a+') finalmotif_seqs = [] finalmotif_length = [] # store length of each motif finalmotif_annot = [] finalmotifs = motif_file.readlin

Re: [Tutor] Need help with arrays

2011-05-04 Thread Alan Gauld
"Patrick P." wrote I hope this is the right way to ask my question, if not, sorry to bother you. Maybe you can tell me who to ask. The way you ask the question is fine but the place is maybe not so good. This is a list for people learning Python but you are really asking about numpy so you

[Tutor] Need help with arrays

2011-05-04 Thread Patrick P .
Hello, I hope this is the right way to ask my question, if not, sorry to bother you. Maybe you can tell me who to ask. Ok so here is my code import numpy as np nH = 2.2 nL = 1.7 welle = 0.5 wurzel = (8.85*10**(-12) *

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread bob gailer
On 5/4/2011 2:31 PM, Spyros Charonis wrote: Hello everyone, I have written a program, as part of a bioinformatics project, that extracts motif sequences (programmatically just strings of letters) from a database and writes them to a file. I have written another script to annotate the database

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread Prasad, Ramit
Your problem is most likely here. for line in seqalign: for i in len(finalmotif_seqs): # for item in finalmotif_seqs: for i in len(finalmotif_annot): # for item in finalmotif_annot: instead of for line in seqalign: for i in xrange(len(finalmotif_seqs)): # for item in

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Prasad, Ramit
Use of string module directly seems to be deprecated; you can access any member functions from the string directly. See below. delimiter = ‘.’ f = open('words.txt', "r") lines = f.readlines() for line in lines: line_items = line.split(delimiter) Also, you can read a single line at a

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Jeff Peery
Greg, You might try… Import sting delimiter = ‘.’ f = open('words.txt', "r") lines = f.readlines() for line in lines: line_items = string.split(line,delimiter) From: tutor-bounces+jeffpeery=seametrics@python.org [mailto:tutor-bounces+jeffpeery=seametrics@python.org] On Behal

Re: [Tutor] Reading elements in a file

2011-05-04 Thread Steve Willoughby
On 04-May-11 11:40, Greg Christian wrote: Python version = 2.7.1 Platform = win32 I am kind of stuck on what is probably a simple thing: If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this” It depends on exactly how "just like" that example the file is.

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread Adam Lucas
On Wed, May 4, 2011 at 13:31, Spyros Charonis wrote: > Hello everyone, > > I have written a program, as part of a bioinformatics project, that > extracts motif sequences (programmatically just strings of letters) from a > database and writes them to a file. > I have written another script to anno

[Tutor] Reading elements in a file

2011-05-04 Thread Greg Christian
Python version = 2.7.1 Platform = win32 I am kind of stuck on what is probably a simple thing: If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this” f = open('words.txt', "r") words = f.read() will read the whole file, is there a way to read just the

[Tutor] Reading elements in a file

2011-05-04 Thread Greg Christian
I am kind of stuck on what is probably a simple thing: If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this” f = open('words.txt', "r") words = f.read() will read the whole file, is there a way to read just the words: first word in that another part

[Tutor] triple-nested for loop not working

2011-05-04 Thread Spyros Charonis
Hello everyone, I have written a program, as part of a bioinformatics project, that extracts motif sequences (programmatically just strings of letters) from a database and writes them to a file. I have written another script to annotate the database file (in plaintext ASCII format) by replacing ev

[Tutor] Problem Automating Internet Explorer Printing

2011-05-04 Thread Jeff Peery
Hello, I'm using the code pasted below to print a document. The code worked great on my XP machine. I moved it to my W7 machine and it gives the error below. The weird thing is that it works great if printing a html doc from the web (such as www.google.com), but it errors when printing a html do

Re: [Tutor] Alternate credentials

2011-05-04 Thread Bill Allen
On May 4, 2011, at 0:57, Tim Golden wrote: > On 04/05/2011 00:18, Alan Gauld wrote: >> Since its more a Windows question than a Python one I suggest you try a >> Windows forum. comp.python.windows might be worth a try? Or even the >> ctypes group? >> >> While we do have some Windows users here

Re: [Tutor] Filtering out unique list elements

2011-05-04 Thread Steven D'Aprano
Spyros Charonis wrote: Dear All, I have built a list with multiple occurrences of a string after some text processing that goes something like this: [cat, dog, cat, cat, cat, dog, dog, tree, tree, tree, bird, bird, woods, woods] I am wondering how to truncate this list so that I only print out

Re: [Tutor] ValueError

2011-05-04 Thread Peter Otten
Kushal Kumaran wrote: > On Tue, May 3, 2011 at 5:31 PM, Peter Otten <__pete...@web.de> wrote: >> >> >> Also you should make the try...except as narrow as possible >> >> try: >> centimeters = float(centimeters) >> except ValueError as e: >> print e >> >> is likely to catch the float conversion whi

Re: [Tutor] ValueError

2011-05-04 Thread Alan Gauld
"Kushal Kumaran" wrote Also you should make the try...except as narrow as possible try: centimeters = float(centimeters) except ValueError as e: print e ... I would have expected it to be the other way. If you cannot reasonable expect to continue after an exception, then the try block shou

Re: [Tutor] Alternate credentials

2011-05-04 Thread Tim Golden
On 04/05/2011 00:18, Alan Gauld wrote: Since its more a Windows question than a Python one I suggest you try a Windows forum. comp.python.windows might be worth a try? Or even the ctypes group? While we do have some Windows users here its not really a python nwewbie type question. True enough.