Re: [Tutor] still breaking chains

2015-04-13 Thread Jim Mooney
> Chaining long strings of operations together in a single statement goes > directly against that principle, and hence is to be avoided. > > Ben Finney > > A hard habit to break after using jQuery as a webmaster ;') -- Jim "Stop, Harold! That bagel has radishes!" "Thank God, Mary - you've saved m

Re: [Tutor] still breaking chains

2015-04-13 Thread Jim Mooney
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 Sy

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] 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