HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
Hello, I wanted to use python to scrub an html file for score data, but I'm having trouble. I'm using HTMLParser, and the parsing seems to fizzle out around line 192 or so. None of the event functions are being called anymore (handle_starttag, handle_endtag, etc.) and I don't understand why,

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
On Oct 24, 4:36 pm, josh logan dear.jay.lo...@gmail.com wrote: Hello, I wanted to use python to scrub an html file for score data, but I'm having trouble. I'm using HTMLParser, and the parsing seems to fizzle out around line 192 or so. None of the event functions are being called anymore

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
On Oct 24, 4:38 pm, josh logan dear.jay.lo...@gmail.com wrote: On Oct 24, 4:36 pm, josh logan dear.jay.lo...@gmail.com wrote: Hello, I wanted to use python to scrub an html file for score data, but I'm having trouble. I'm using HTMLParser, and the parsing seems to fizzle out around

Re: how can this iterator be optimized?

2009-02-14 Thread josh logan
On Feb 13, 7:44 pm, Basilisk96 basilis...@gmail.com wrote: On Feb 12, 1:15 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: I usually strive for comprehensions if a for loop can be reduced to such. Any particular reason? Only two. 1.) I was impressed by their clarity

Re: how can this iterator be optimized?

2009-02-12 Thread josh logan
On Feb 11, 8:22 pm, Basilisk96 basilis...@gmail.com wrote: Hello all, I have the following function that uses an intermediate iterator rawPairs: def MakePairs(path):     import os     import operator     join = os.path.join     rawPairs = (         (join(path, s), func(s))         for

Re: Read Only attributes, auto properties and getters and setters

2009-02-12 Thread josh logan
On Feb 12, 10:58 am, TechieInsights gdoerm...@gmail.com wrote: Oh... one other thing that would be really cool is to do this with AOP/ descriptors!  I just haven't been able to get that to work either. Basics... @readonly class MyClass(object):         def __init__(self, x):                

Re: Read Only attributes, auto properties and getters and setters

2009-02-12 Thread josh logan
On Feb 12, 12:27 pm, TechieInsights gdoerm...@gmail.com wrote: Ok... for some closure I have written a class to automate the process.  It takes getters and setters and deleters and then sets the property automatically.  Sweet! class AutoProperty(type):         def __new__(cls, name, bases,

Re: Question about sorted in Python 3.0rc1

2008-09-22 Thread josh logan
On Sep 22, 3:41 am, Arnaud Delobelle [EMAIL PROTECTED] wrote: On 22 Sep, 04:05, josh logan [EMAIL PROTECTED] wrote: Hello, I have 2 questions. Say I have this class: class Player(object):     def __init__(self, fname, lname, score):         self.score = score         self.fname

Re: Question about sorted in Python 3.0rc1

2008-09-22 Thread josh logan
On Sep 22, 7:32 am, Sion Arrowsmith [EMAIL PROTECTED] wrote: josh logan  [EMAIL PROTECTED] wrote: sorted(P) # throws TypeError: unorderable types Player() Player() The sorted function works when I define __lt__. I must be misreading the documentation, because I read for the documentation

Re: Question about sorted in Python 3.0rc1

2008-09-22 Thread josh logan
On Sep 22, 9:29 am, Hrvoje Niksic [EMAIL PROTECTED] wrote: josh logan [EMAIL PROTECTED] writes: sorted(P) # throws TypeError: unorderable types Player() Player() The sorted function works when I define __lt__. I must be misreading the documentation, because I read for the documentation

Question about sorted in Python 3.0rc1

2008-09-21 Thread josh logan
Hello, I have 2 questions. Say I have this class: class Player(object): def __init__(self, fname, lname, score): self.score = score self.fname = fname self.lname = lname def __cmp__(self, other): return (-cmp(self.score, other.score) or

Re: String/Number Conversion

2008-09-06 Thread josh logan
On Sep 6, 5:04 pm, Andreas Hofmann [EMAIL PROTECTED] wrote: Hello Folks! I've got a little problem here, which which really creeps me out at the moment. I've got some strings, which only contain numbers plus eventually one character as si-postfix (k for kilo, m for mega, g for giga). I'm

Re: Python 3.0b2 cannot map '\u12b'

2008-09-01 Thread josh logan
On Sep 1, 8:19 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Mon, 01 Sep 2008 02:27:54 -0400, Terry Reedy wrote: I doubt the OP 'chose' cp437.  Why does Python using cp437 even when the default encoding is utf-8? On WinXP   sys.getdefaultencoding() 'utf-8'   s='\u012b'  

Re: Eleganz way to get rid of \n

2008-09-01 Thread josh logan
On Sep 1, 9:25 am, Hans Müller [EMAIL PROTECTED] wrote: Hello, I'm quite often using this construct: for l in open(file, r):         do something here, l contains the \n or \r\n on windows at the end. I get rid of it this way: for l in open(file, r):         while l[-1] in \r\n:      

Re: SAXReaderNotAvailble: No parsers found

2008-09-01 Thread josh logan
On Aug 30, 8:59 pm, josh logan [EMAIL PROTECTED] wrote: Vincent Yau [EMAIL PROTECTED] writes: I am trying to use Python SAX API to parse XML files.  I do see expat.py somewhere underneath my Python 2.1.1 installation (on Solaris). But I got this error when invoking

Re: Eleganz way to get rid of \n

2008-09-01 Thread josh logan
On Sep 1, 9:41 am, Wojtek Walczak [EMAIL PROTECTED] wrote: On Mon, 01 Sep 2008 15:25:03 +0200, Hans Müller wrote: I'm quite often using this construct: for l in open(file, r):    do something Has someone a better solution ? The most general would be to use rstrip() without arguments:

Python 3.0b2 cannot map '\u12b'

2008-08-31 Thread josh logan
Hello, I am using Python 3.0b2. I have an XML file that has the unicode character '\u012b' in it, which, when parsed, causes a UnicodeEncodeError: 'charmap' codec can't encode character '\u012b' in position 26: character maps to undefined This happens even when I assign this character to a

Re: How to ignore the first line of the text read from a file

2008-08-30 Thread josh logan
On Aug 28, 3:47 am, Santiago Romero [EMAIL PROTECTED] wrote: I want to read text line-by-line from a text file, but want to ignore only the first line. I know how to do it in Java (Java has been my primary language for the last couple of years) and following is what I have in Python, but I

Re: How to check is something is a list or a dictionary or a string?

2008-08-30 Thread josh logan
But this changes with Python 3, right? On Aug 30, 7:15 am, Ken Starks [EMAIL PROTECTED] wrote: George Sakkis wrote: On Aug 29, 12:16 pm, [EMAIL PROTECTED] wrote: Hi, How to check if something is a list or a dictionary or just a string? Eg: for item in self.__libVerDict.itervalues():

SAXReaderNotAvailble: No parsers found

2008-08-30 Thread josh logan
Vincent Yau [EMAIL PROTECTED] writes: I am trying to use Python SAX API to parse XML files. I do see expat.py somewhere underneath my Python 2.1.1 installation (on Solaris). But I got this error when invoking the xml.sax.make_parser() call. Any tip/help much appreciated. You should

Re: Concise way to format list/array to custom(hex) string

2008-08-02 Thread josh logan
On Aug 2, 9:29 am, Grant Edwards [EMAIL PROTECTED] wrote: On 2008-08-02, Zoltán Nagy [EMAIL PROTECTED] wrote: Kurien Mathew írta: Hello, What will be a concise efficient way to convert a list/array.array of n elements into a hex string? For e.g. given the bytes [116, 111, 110,

Where is the correct round() method?

2008-07-27 Thread josh logan
Hello, I need a round function that _always_ rounds to the higher integer if the argument is equidistant between two integers. In Python 3.0, this is not the advertised behavior of the built-in function round() as seen below: round(0.5) 0 round(1.5) 2 round(2.5) 2 I would think this is a

Re: Where is the correct round() method?

2008-07-27 Thread josh logan
On Jul 27, 7:58 pm, Gary Herron [EMAIL PROTECTED] wrote: josh logan wrote: Hello, I need a round function that _always_ rounds to the higher integer if the argument is equidistant between two integers. In Python 3.0, this is not the advertised behavior of the built-in function round

Re: Where is the correct round() method?

2008-07-27 Thread josh logan
On Jul 27, 8:45 pm, pigmartian [EMAIL PROTECTED] wrote: it could be that 3.0 is using banker's rounding --- rounding to the even digit.  the idea behind it behind it being to reduce error accumulation when working with large sets of values. Works for me on Python 2.5 on Linux running on