Re: [Tutor] still breaking chains

2015-04-12 Thread boB Stepp
On Sun, Apr 12, 2015 at 6:47 PM, Ben Finney wrote: [...] > One important principle to follow is to write your statements to be very > simple, so that when something goes wrong it is as easy as possible to > read the statement and understand what it *actually* says. +1! This principle I have fou

Re: [Tutor] still breaking chains

2015-04-12 Thread Steven D'Aprano
On Sun, Apr 12, 2015 at 11:03:07AM -0700, Jim Mooney wrote: > If join returns a string, why am I getting a syntax error when I try to > slice it? Because you have a syntax error. Syntax error means you have written something which the Python compiler cannot understand, because the syntax is wr

Re: [Tutor] still breaking chains

2015-04-12 Thread Ben Finney
Jim Mooney writes: > If join returns a string, why am I getting a syntax error when I try to > slice it? > > >>> 'alfabeta'[2:5] > 'fab' > >>> ''.join(['a', 'l', 'f', 'a', 'b', 'e', 't', 'a')[2:5] > SyntaxError: invalid syntax This demonstrates the primary problem with so-called “chaining”. You

Re: [Tutor] Please disable “digest” mode in order to participate

2015-04-12 Thread Ben Finney
Laura Creighton writes: > In a message of Sun, 12 Apr 2015 18:05:16 +1000, Ben Finney writes: > >Please disable that in order to receive individual messages, so you > >can participate properly: responding to individual messages that the > >rest of us see. > > Or see if your mailer, like mine, has

Re: [Tutor] still breaking chains

2015-04-12 Thread Danny Yoo
On Apr 12, 2015 4:00 PM, "Jim Mooney" wrote: > > If join returns a string, why am I getting a syntax error when I try to > slice it? > > >>> 'alfabeta'[2:5] > 'fab' > >>> ''.join(['a', 'l', 'f', 'a', 'b', 'e', 't', 'a')[2:5] > SyntaxError: invalid syntax If you're seeing a SyntaxError, don't loo

[Tutor] still breaking chains

2015-04-12 Thread Jim Mooney
If join returns a string, why am I getting a syntax error when I try to slice it? >>> 'alfabeta'[2:5] 'fab' >>> ''.join(['a', 'l', 'f', 'a', 'b', 'e', 't', 'a')[2:5] SyntaxError: invalid syntax -- Jim ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] why no chaining?

2015-04-12 Thread Alan Gauld
On 12/04/15 11:16, Timo wrote: Personally I think it would help if the first lines for these methods read like: remove(...) -> None L.remove...etc Are you using Python 2? Because this is what I get in Python 3: Yes, I just fired up the default python which is 2.7. I never thought to che

Re: [Tutor] Please disable “digest” mode in order to participate (was: Tutor Digest, Vol 134, Issue 32 - amazing range)

2015-04-12 Thread Laura Creighton
In a message of Sun, 12 Apr 2015 18:05:16 +1000, Ben Finney writes: >Jim, you are evidently receiving “digest” messages from this forum. > >Please disable that in order to receive individual messages, so you can >participate properly: responding to individual messages that the rest of >us see. > >E

Re: [Tutor] On learning Fortran and C++ for scientific computing

2015-04-12 Thread Laura Creighton
In a message of Sun, 12 Apr 2015 10:25:54 +0400, "Vick" writes: >S 0 to 1e+31> 1/sqrt(.86 *(1+z)^4 + .282 * (1+z)^3 - .86 >*(1+z)^2 + .718) if you try this integration you will get completely >wrong numbers on computing devices that do not possess ultra-high precision >and accuracy.

Re: [Tutor] why no chaining?

2015-04-12 Thread Timo
Op 12-04-15 om 09:58 schreef Alan Gauld: Aside: Normally you would use the help() function to find out how methods work and what they return but sadly the documentation for the in-place methods doesn't indicate the return is None. Some of them have a warning that its "IN PLACE" but remove does n

Re: [Tutor] On learning Fortran and C++ for scientific computing

2015-04-12 Thread Peter Otten
Vick wrote: > So can Fortran crunch 250 digits numbers in an integration formula under 3 > seconds with the same computing parameters as above? Or is Python better > at it? So by better you mean faster. Pure CPython is usually much slower than Fortran, but as there are many optimised libraries

[Tutor] Please disable “digest” mode in order to participate (was: Tutor Digest, Vol 134, Issue 32 - amazing range)

2015-04-12 Thread Ben Finney
Jim Mooney writes: > That's really cool. Worth making a dumb mistake to find it out ;') Jim, you are evidently receiving “digest” messages from this forum. Please disable that in order to receive individual messages, so you can participate properly: responding to individual messages that the re

Re: [Tutor] why no chaining?

2015-04-12 Thread Alan Gauld
On 12/04/15 07:06, Jim Mooney wrote: I thought I'd get [2,3,4,5] from this but instead I get nothing. Why isn't it chaining? q = list(set([1,2,3,1,4,1,5,1,5])).remove(1) q Because that's just the way it was designed. It's common in Python for methods that modify an object to return None. I d

[Tutor] Tutor Digest, Vol 134, Issue 32 - amazing range

2015-04-12 Thread Jim Mooney
> Range objects are special: not only do they produce values lazily as > needed, but they also support len(), indexing, slicing, and membership > testing, none of which generators are capable of doing: > > Steve - That's really cool. Worth making a dumb mistake to find it out ;') Jim Today is

[Tutor] why no chaining?

2015-04-12 Thread Jim Mooney
I thought I'd get [2,3,4,5] from this but instead I get nothing. Why isn't it chaining? >>> q = list(set([1,2,3,1,4,1,5,1,5])).remove(1) >>> q >>> -- Jim Today is the day that would have been yesterday if tomorrow was today ___ Tutor maillist - Tuto