Re: [Tutor] Value Error

2013-06-13 Thread Dave Angel
On 06/13/2013 04:09 AM, eryksun wrote: On Wed, Jun 12, 2013 at 6:31 PM, Dave Angel wrote: i = complex(0,1) >>> 1j 1j I had forgotten that notation for a complex literal. I knew the magic syntax had j in it, but didn't remember it needs to be part of the numeric token. Of cou

Re: [Tutor] Value Error

2013-06-13 Thread eryksun
On Wed, Jun 12, 2013 at 6:31 PM, Dave Angel wrote: > i = complex(0,1) >>> 1j 1j http://en.wikipedia.org/wiki/Imaginary_unit#Alternative_notations cmath.sqrt(float((math.e **(i * math.pi)).real)) The real/imag attributes are already floats: >>> from math import e, pi, si

Re: [Tutor] Value Error

2013-06-12 Thread Jim Mooney
On 12 June 2013 17:08, Marc Tompkins wrote: > On Wed, Jun 12, 2013 at 3:31 PM, Dave Angel wrote: > >> >>> cmath.sqrt(float((math.e **(i * math.pi)).real)) >> 1j >> > Sh*t just got real. > I give up. When I got to Complex Analysis I decided to enlist instead. And that was during Vie

Re: [Tutor] Value Error

2013-06-12 Thread Alan Gauld
On 13/06/13 01:08, Marc Tompkins wrote: On Wed, Jun 12, 2013 at 3:31 PM, Dave Angel mailto:da...@davea.name>> wrote: >>> cmath.sqrt(float((math.e **(i * math.pi)).real)) 1j Sh*t just got real. no, it's imaginary. :-) -- Alan G Author of the Learn to Program web site http://www.alan

Re: [Tutor] Value Error

2013-06-12 Thread Marc Tompkins
On Wed, Jun 12, 2013 at 3:31 PM, Dave Angel wrote: > >>> cmath.sqrt(float((math.e **(i * math.pi)).real)) > 1j > Sh*t just got real. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/li

Re: [Tutor] Value Error

2013-06-12 Thread Dave Angel
On 06/12/2013 06:07 PM, Jim Mooney wrote: On 12 June 2013 14:16, Steve Willoughby wrote: or if you try to take the square root of a negative number, etc. Or the log of -10. Although sqrt(-1) works fine for cmath.sqrt(-1) - I think I get it. Come to think of it you can do cmath.log(-10), bu

Re: [Tutor] Value Error

2013-06-12 Thread Jim Mooney
On 12 June 2013 14:16, Steve Willoughby wrote: > or if you try to take the square root of a negative number, etc. > Or the log of -10. Although sqrt(-1) works fine for cmath.sqrt(-1) - I think I get it. Come to think of it you can do cmath.log(-10), but that's getting scary ;') Jim ___

Re: [Tutor] Value Error

2013-06-12 Thread Roel Schroeven
Jim Mooney schreef: Although I'm not sure why int('blah') wouldn't be a type error rather than a value error. Because passing a string to int() is perfectly okay, as long as the string has an appropriate value: int('42') works, int('forty two') raises ValueError. -- "People almost invariabl

Re: [Tutor] Value Error

2013-06-12 Thread Steve Willoughby
int('blah') is not a type error because the int() function is expecting to be given a string, and it was given a string. The 'blah' is of the correct type. The problem is that int() couldn't do anything useful with the value of that string. Steve On 12-Jun-2013, at 14:41, Jim Mooney wrote: >

Re: [Tutor] Value Error

2013-06-12 Thread Steve Willoughby
or if you try to take the square root of a negative number, etc. On 12-Jun-2013, at 14:06, Sander Sweers wrote: > On 06/12/2013 10:49 PM, Jim Mooney wrote: >> Raised when a built-in operation or function receives an argument that has >> the right type but an inappropriate value, and the situatio

Re: [Tutor] Value Error

2013-06-12 Thread Jim Mooney
Dave Angel import math > print math.sqrt(-1) Ah, that's what I was looking for. I already saw it trip on type mismatches like int('blah'). I was looking for what would be an actual inappropriate value that was still the right type. Although I'm not sure why int('blah') wouldn't be a type e

Re: [Tutor] Value Error

2013-06-12 Thread Dave Angel
On 06/12/2013 04:49 PM, Jim Mooney wrote: I'm going through the exceptions so I can recall and use the basic ones (not much use for unicode errors at this point ;') But I'm puzzled by an aspect of the Value Error: *exception *ValueError Raised when a built-in operation or function receives an a

Re: [Tutor] Value Error

2013-06-12 Thread Sander Sweers
On 06/12/2013 10:49 PM, Jim Mooney wrote: > Raised when a built-in operation or function receives an argument that has > the right type but an inappropriate value, and the situation is not > described by a more precise exception such as > IndexError

[Tutor] Value Error

2013-06-12 Thread Jim Mooney
I'm going through the exceptions so I can recall and use the basic ones (not much use for unicode errors at this point ;') But I'm puzzled by an aspect of the Value Error: *exception *ValueError Raised when a built-in operation or function receives an argument that has the right type but an inapp

Re: [Tutor] Value Error solved. Another question

2005-02-14 Thread Kent Johnson
Ron Nixon wrote: Ignore my first posting. Here's what I'm trying to do. I want to extract headlines from a newspaper's website using this code. It works, but I want to match the second group in (.*) and print that out. Sugguestions import urllib, re pattern = re.compile(""" href="(.*)">(.*)""", re.

[Tutor] Value Error solved. Another question

2005-02-13 Thread Ron Nixon
Ignore my first posting. Here's what I'm trying to do. I want to extract headlines from a newspaper's website using this code. It works, but I want to match the second group in (.*) and print that out. Sugguestions import urllib, re pattern = re.compile("""(.*)""", re.DOTALL) page = urllib.urlope

[Tutor] Value Error message

2005-02-13 Thread Ron Nixon
Trying to scrape some headlines off a newspaper with this code: import urllib, re pattern = re.compile("""(.*)""", re.DOTALL) page = urllib.urlopen("http://www.startribune.com";).read() for (headline, code, description) in pattern.findall(page): print (headline, code, description) I'm gett