Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread eryksun
On Tue, Jun 25, 2013 at 11:35 AM, Peter Otten <__pete...@web.de> wrote: > eryksun wrote: > >> Constant folding for binary operations has a length limit of 20 for >> sequences: >> >> >>> dis.dis(lambda: '0123456789' + '0123456789' + '0') >> 1 0 LOAD_CONST 3 ('012345

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread Peter Otten
eryksun wrote: > Constant folding for binary operations has a length limit of 20 for > sequences: > > >>> dis.dis(lambda: '0123456789' + '0123456789' + '0') > 1 0 LOAD_CONST 3 ('0123456789 > 0123456789') >

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread eryksun
On Tue, Jun 25, 2013 at 10:11 AM, Peter Otten <__pete...@web.de> wrote: > > In older Pythons for ("alpha" "beta") the compiler would merge the two > strings into one whereas ("alpha" + "beta") would trigger a str.__add__() > call at runtime. Nowadays the peephole optimiser recognizes ("alpha" + > "

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread Peter Otten
Albert-Jan Roskam wrote: > ___ >>From: eryksun >>To: Jim Mooney >>Cc: tutor@python.org >>Sent: Tuesday, June 25, 2013 2:14 PM >>Subject: Re: [Tutor] mistaken about splitting expressions over lines > > > >> >>

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread Albert-Jan Roskam
___ >From: eryksun >To: Jim Mooney >Cc: tutor@python.org >Sent: Tuesday, June 25, 2013 2:14 PM >Subject: Re: [Tutor] mistaken about splitting expressions over lines > >    >>> a = ('this'  # this way >    ...   

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-25 Thread eryksun
On Mon, Jun 24, 2013 at 9:58 PM, Dave Angel wrote: > > Alternatively, you can also use the statement continuation mechanism, > whereby the last character of the line is a backslash. Using that approach > you can break almost anywhere, except within a token or inside a string > literal. Also, the

Re: [Tutor] mistaken about splitting expressions over lines

2013-06-24 Thread Dave Angel
On 06/24/2013 09:48 PM, Jim Mooney wrote: For some reason I took the impression that you could split expressions over lines. However, this works: word = 'spam' new_word = word + 'eggs' print(word) But this is a syntax error: word = 'spam' new_word = word + 'eggs' print(word) That's easy to

[Tutor] mistaken about splitting expressions over lines

2013-06-24 Thread Jim Mooney
For some reason I took the impression that you could split expressions over lines. However, this works: word = 'spam' new_word = word + 'eggs' print(word) But this is a syntax error: word = 'spam' new_word = word + 'eggs' print(word) That's easy to avoid, but what if you're adding five or six