Re: [Tutor] Html entities, beautiful soup and unicode

2010-01-19 Thread Gerard Flanagan
andy wrote: Hi people I'm using beautiful soup to rip the uk headlines from the uk bbc page. This works rather well but there is the problem of html entities which appear in the xml feed. Is there an elegant/simple way to convert them into the "standard" output? By this I mean £ going to  ? or

Re: [Tutor] Algorithm for combination analysis suggestion.

2010-02-12 Thread Gerard Flanagan
Matthew Matson wrote: Hi Tutors, I am looking for the proper approach regarding the analysis of a dictionary of combinations I have. What I need to do is read from a supplied text file that has a unique ID and that unique ID's associated combination of elements. So let's say I have the fol

Re: [Tutor] nested list help

2010-07-27 Thread Gerard Flanagan
Vikram K wrote: Suppose i have this nested list: >>> x [['NM100', 3, 4, 5, 6, 7], ['NM100', 10, 11, 12, 13], ['NM200', 15, 16, 17]] >>> for i in x: ... print i ... ['NM100', 3, 4, 5, 6, 7] ['NM100', 10, 11, 12, 13] ['NM200', 15, 16, 17] >>> how do i obtain from the above the following nest

Re: [Tutor] regexp: a bit lost

2010-09-30 Thread Gerard Flanagan
Alex Hall wrote: Hi, once again... I have a regexp that I am trying to use to make sure a line matches the format: [c*]n [c*]n n where c* is (optionally) 0 or more non-numeric characters and n is any numeric character. The spacing should not matter. These should pass: v1 v2 5 2 someword7 3 whi

Re: [Tutor] regexp: a bit lost

2010-09-30 Thread Gerard Flanagan
with coffee: yes = """ v1 v2 5 2 someword7 3 """.splitlines()[1:] no = """ word 2 3 1 2 """.splitlines()[1:] import re pattern = "(\w*\d\s+?)(\w*\d\s+?)(\d)$" rx = re.compile(pattern) for line in yes: m = rx.match(line) assert m print([part.rstrip() for part in m.groups()]) f

Re: [Tutor] Parsing html tables and using numpy for subsequent processing

2009-09-16 Thread Gerard Flanagan
David Kim wrote: Hello all, I've finally gotten around to my 'learn how to parse html' project. For those of you looking for examples (like me!), hopefully it will show you one potentially thickheaded way to do it. [...] The code can be found at pastebin: http://financialpython.pastebin.com

Re: [Tutor] Still Trying to Understand GAE

2009-09-16 Thread Gerard Flanagan
ad...@gg-lab.net wrote: The "google" directoy has an empty __init__.py file (well, if we want to be completely correct it contains some commented -#- lines). Same for "appengine", "net" and "pyglib". As they all have an __init__.py file, they should be consiedered as modules from the python inter

Re: [Tutor] Logfile Manipulation

2009-11-09 Thread Gerard Flanagan
Stephen Nelson-Smith wrote: Hi, Any advice or experiences? go here and download the pdf! http://www.dabeaz.com/generators-uk/ Someone posted this the other day, and I went and read through it and played around a bit and it's exactly what you're looking for - plus it has one vs. slid

Re: [Tutor] Find Integer co-ordinates lying on a circle

2009-11-15 Thread Gerard Flanagan
Shashwat Anand wrote: > How to find all possible integer co-ordinates lying on a circle of given radius 'r'. > If given the upper bound of 'r', I want to calculate all given co-ordinates lying for 0 <= r <= n > > Let's say the upper bound of radius is 5 > All possible results are: > radius 'r'

Re: [Tutor] elementtree question

2009-11-19 Thread Gerard Flanagan
Albert-Jan Roskam wrote: Hi, I have an elementtree question that probably reflects my inexperience with xml processing (and/or with Python). The xml file is a stream of the Spss Clementine program. Each stream consists of, among others, nodes. Each nodes has properties, among which "tooltipt

Re: [Tutor] Help with a Dictionary

2010-01-07 Thread Gerard Flanagan
Garry Bettle wrote: Howdy all, I hope this message finds you all well. I have a list that I output in the following order: 2010-01-07 1103 Sund A7 450m 2010-01-07 Sheff A7 500m 2010-01-07 1119 Sund A6 450m 2010-01-07 1128 Sheff A6 500m 2010-01-07 1134 Sund A5 450m 2010-01-07 1142 Sheff A7