Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Chris Angelico
On Mon, Dec 3, 2012 at 6:30 PM, Steven D'Aprano wrote: > Yeah, in hindsight it was a pretty crappy example. But this sort of > dynamism really is useful: > > def testRaises(exc, func, *args): > try: > result = func(*args) > except exc: > return > raise AssertionError("e

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Steven D'Aprano
On Mon, 03 Dec 2012 16:24:50 +1100, Chris Angelico wrote: > On Mon, Dec 3, 2012 at 8:31 AM, Steven D'Aprano > wrote: >> Consider this piece of legal Python code: >> >> Err = None >> if condition(x) > 100: >> Err = OneException >> elif another_condition(x): >> Err = AnotherException >> try

Re: Using Xpath to parse a Yahoo Finance page

2012-12-02 Thread Stefan Behnel
MRAB, 03.12.2012 03:25: > On 2012-12-03 01:23, Jason Hsu wrote: >> I'm trying to extract the data on "total assets" from Yahoo Finance using >> Python 2.7 and lxml. >> >> Here is a special test script I set up to work on this issue: >> >> import urllib >> import lxml >> import lxml.h

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Chris Angelico
On Mon, Dec 3, 2012 at 8:31 AM, Steven D'Aprano wrote: > Consider this piece of legal Python code: > > Err = None > if condition(x) > 100: > Err = OneException > elif another_condition(x): > Err = AnotherException > try: > spam(a, b, c) > except Err: > recover() Legal it may be, b

Re: Using Xpath to parse a Yahoo Finance page

2012-12-02 Thread Jason Hsu
On Sunday, December 2, 2012 8:25:45 PM UTC-6, MRAB wrote: > > list_row2 = doc2.xpath(u'.//td[strong[contains(text(),"Total > > Assets")]]/following-sibling::td/strong/text()') > Thanks, MRAB. Your suggestion works! -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Xpath to parse a Yahoo Finance page

2012-12-02 Thread MRAB
On 2012-12-03 01:23, Jason Hsu wrote: I'm trying to extract the data on "total assets" from Yahoo Finance using Python 2.7 and lxml. Here is a special test script I set up to work on this issue: import urllib import lxml import lxml.html url_local1 = "http://www.smartmone

Using Xpath to parse a Yahoo Finance page

2012-12-02 Thread Jason Hsu
I'm trying to extract the data on "total assets" from Yahoo Finance using Python 2.7 and lxml. Here is a special test script I set up to work on this issue: import urllib import lxml import lxml.html url_local1 = "http://www.smartmoney.com/quote/FAST/?story=financials&timewin

Re: setup.py Choosing Older Compiler On Windows

2012-12-02 Thread Irmen de Jong
On 2-12-2012 22:06, Dave Angel wrote: > On 12/02/2012 09:34 AM, Ami Tavory wrote: >> Hello, >> >> I'm porting a C++ extension module to a Windows machine that has both VC8 >> and VC10 installed. Unfortunately, `setup.py build` tries to build using >> VC8, which fails (the extension uses C++ sta

Re: Textmining

2012-12-02 Thread alex23
On Dec 1, 7:27 pm, subhabangal...@gmail.com wrote: > http://pypi.python.org/pypi/textmining/1.0 > I am not getting how to download and use it. Did you look at any of the documentation on its home page? http://www.christianpeccei.com/projects/textmining/ > The latest version (1.0) is available fro

Re: loops

2012-12-02 Thread Rhodri James
On Sun, 02 Dec 2012 22:28:48 -, Verde Denim wrote: Nicely done! That fixed it! Is that a version feature or should I take what I find in these books with a grain of salt? It's a difference between Python 2 and Python 3 (which is almost certainly what your book told you to). The other f

Re: loops

2012-12-02 Thread MRAB
On 2012-12-02 22:28, Verde Denim wrote: On 12/02/2012 04:43 PM, Mitya Sirenef wrote: On 12/02/2012 04:39 PM, Verde Denim wrote: I'm just getting into py coding, and have come across an oddity in a py book - while loops that don't work as expected... [snip] This same loop structure appears i

Re: loops

2012-12-02 Thread Verde Denim
On 12/02/2012 04:43 PM, Mitya Sirenef wrote: > On 12/02/2012 04:39 PM, Verde Denim wrote: >> I'm just getting into py coding, and have come across an oddity in a py >> book - while loops that don't work as expected... >> >> import random >> >> MIN = 1 >> MAX = 6 >> >> def main(): >> again = 'y

Re: Splitting Tree

2012-12-02 Thread Cameron Simpson
On 02Dec2012 07:02, subhabangal...@gmail.com wrote: | On Sunday, December 2, 2012 5:39:32 PM UTC+5:30, subhaba...@gmail.com wrote: | > I am using NLTK and I used the following command, | > chunk=nltk.ne_chunk(tag) | > | > print "The Chunk of the Line Is:",chunk | > | > The Chunk of the Line Is:

Re: loops

2012-12-02 Thread Steven D'Aprano
On Sun, 02 Dec 2012 16:39:07 -0500, Verde Denim wrote: > I'm just getting into py coding, and have come across an oddity in a py > book - while loops that don't work as expected... This error has nothing to do with the while loop. Read the error message that Python gives you: > Traceback (most

Re: Python Noob Question.

2012-12-02 Thread Steven D'Aprano
On Sun, 02 Dec 2012 12:33:58 -0800, Owatch wrote: > Sorry, but I was redirected here via a thread on another forum > concerning where to find help for Python. (Python-forums.org not working > for me) > > I wanted to ask if there was any way I could write a simple Python > Temperature program. Whe

Re: loops

2012-12-02 Thread Chris Angelico
On Mon, Dec 3, 2012 at 8:39 AM, Verde Denim wrote: > again = input('Roll again? (y = yes): ') > > Roll again? (y = yes): y > Traceback (most recent call last): > File "dice_roll.py", line 17, in > main() > File "dice_roll.py", line 15, in main > again = input('Roll again? (y =

Re: loops

2012-12-02 Thread Mitya Sirenef
On 12/02/2012 04:39 PM, Verde Denim wrote: I'm just getting into py coding, and have come across an oddity in a py book - while loops that don't work as expected... import random MIN = 1 MAX = 6 def main(): again = 'y' while again == 'y': print('Rolling...') print(

loops

2012-12-02 Thread Verde Denim
I'm just getting into py coding, and have come across an oddity in a py book - while loops that don't work as expected... import random MIN = 1 MAX = 6 def main(): again = 'y' while again == 'y': print('Rolling...') print('Values are: ') print(random.randint(MIN,

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Steven D'Aprano
On Sun, 02 Dec 2012 12:25:22 -0500, Roy Smith wrote: > This is kind of weird (Python 2.7.3): > > try: > print "hello" > except foo: > print "foo" > > prints "hello". The problem (IMHO) is that apparently the except clause > doesn't get evaluated until after some exception is caught. Wh

Re: setup.py Choosing Older Compiler On Windows

2012-12-02 Thread Dave Angel
On 12/02/2012 09:34 AM, Ami Tavory wrote: > Hello, > > I'm porting a C++ extension module to a Windows machine that has both VC8 > and VC10 installed. Unfortunately, `setup.py build` tries to build using > VC8, which fails (the extension uses C++ standard libraries that VC didn't > used to hav

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Terry Reedy
On 12/2/2012 12:25 PM, Roy Smith wrote: This is kind of weird (Python 2.7.3): try: print "hello" except foo: print "foo" prints "hello". The problem (IMHO) is that apparently the except clause doesn't get evaluated until after some exception is caught. Which means it never notices t

Python Noob Question.

2012-12-02 Thread Owatch
Sorry, but I was redirected here via a thread on another forum concerning where to find help for Python. (Python-forums.org not working for me) I wanted to ask if there was any way I could write a simple Python Temperature program. Where essentially it somehow (Now sure how, I'm a noob remember)

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Hans Mulder
On 2/12/12 18:25:22, Roy Smith wrote: > This is kind of weird (Python 2.7.3): > > try: > print "hello" > except foo: > print "foo" > > prints "hello". The problem (IMHO) is that apparently the except clause > doesn't get evaluated until after some exception is caught. Which means > it

Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Roy Smith
This is kind of weird (Python 2.7.3): try: print "hello" except foo: print "foo" prints "hello". The problem (IMHO) is that apparently the except clause doesn't get evaluated until after some exception is caught. Which means it never notices that foo is not defined until it's too late

Re: List problem

2012-12-02 Thread subhabangalore
On Sunday, December 2, 2012 9:29:22 PM UTC+5:30, Thomas Bach wrote: > On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote: > > > > > > len([x for x in l if x[1] == 'VBD']) > > > > > > > Another way is > > > > sum(1 for x in l if x[1] == 'VBD') > > > > which saves the list creati

Re: List problem

2012-12-02 Thread Thomas Bach
On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote: > > len([x for x in l if x[1] == 'VBD']) > Another way is sum(1 for x in l if x[1] == 'VBD') which saves the list creation. Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

New tutorials

2012-12-02 Thread Mitya Sirenef
Hi everyone, I'm making a series of python tutorials and I've just finished the introductory part: http://lightbird.net/larks/intro.html Feedback is appreciated.. - mitya -- http://mail.python.org/mailman/listinfo/python-list

Re: List problem

2012-12-02 Thread Lutz Horn
Him Am 02.12.2012 um 16:03 schrieb subhabangal...@gmail.com: > I have a list of the following pattern, > > [("''", "''"), ('Eastern', 'NNP'), ('Army', 'NNP'), ('Commander', 'NNP'), > ('Lt', 'NNP'), ('Gen', 'NNP'), ('Dalbir', 'NNP'), ('Singh', 'NNP'), ('Suhag', > 'NNP'), ('briefed', 'VBD'), ('th

Re: Splitting Tree

2012-12-02 Thread subhabangalore
On Sunday, December 2, 2012 5:39:32 PM UTC+5:30, subhaba...@gmail.com wrote: > Dear Group, > > > > I am using NLTK and I used the following command, > > > > chunk=nltk.ne_chunk(tag) > > print "The Chunk of the Line Is:",chunk > > > > > > The Chunk of the Line Is: (S > > ''/'' > >

List problem

2012-12-02 Thread subhabangalore
Dear Group, I have a list of the following pattern, [("''", "''"), ('Eastern', 'NNP'), ('Army', 'NNP'), ('Commander', 'NNP'), ('Lt', 'NNP'), ('Gen', 'NNP'), ('Dalbir', 'NNP'), ('Singh', 'NNP'), ('Suhag', 'NNP'), ('briefed', 'VBD'), ('the', 'DT'), ('Army', 'NNP'), ('chief', 'NN'), ('on', 'IN'),

setup.py Choosing Older Compiler On Windows

2012-12-02 Thread Ami Tavory
Hello, I'm porting a C++ extension module to a Windows machine that has both VC8 and VC10 installed. Unfortunately, `setup.py build` tries to build using VC8, which fails (the extension uses C++ standard libraries that VC didn't used to have). Is there a way to get setup.py to use VC10 (prefe

Re: Imaging libraries in active development?

2012-12-02 Thread Luis Pedro Coelho
Alasdair McAndrew on Thu, 29 Nov 2012 wrote: > Probably the combinations of OpenCV, Scipy.ndimage and scikits-image > would cover pretty much all of my needs. Hi, All of those (+ mahotas, which is the package I wrote & imread which might be useful for microscopy file formats) will work on nu

Splitting Tree

2012-12-02 Thread subhabangalore
Dear Group, I am using NLTK and I used the following command, chunk=nltk.ne_chunk(tag) print "The Chunk of the Line Is:",chunk The Chunk of the Line Is: (S ''/'' It/PRP is/VBZ virtually/RB a/DT homecoming/NN ,/, ''/'' said/VBD (PERSON Gen/NNP Singh/NNP) on/IN arrival/NN)