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