On Sun, Nov 27, 2016 at 7:34 AM, rengel wrote:
If you change 's.splitlines(True)' to 's.splitlines(False) in g.
> splitLines
> , your interface to g doesn't change at all.
>
This change would be catastrophic.
If you change how lines are split, then you have to
True, but now I *do* understand why I am *not *going to make the changes!
>
> As elegant as changes the changes seem, my background mind has been
> *screaming* at me that they are a bad, bad, bad idea.
>
> I inserted a new_lines switch in linescanner.py and actually starting
> converting the
On Sunday, November 27, 2016 at 12:33:36 PM UTC+1, Edward K. Ream wrote:
>
> On Sun, Nov 27, 2016 at 5:21 AM, rengel > wrote:
>
>
> v._bodyString = '\n'.join(v._import_lines) + '\n'
>>
>
> No. It inserts a newline when v._import_lines is [].
>
> EKR
>
Well, this is a
On Sun, Nov 27, 2016 at 4:15 AM, Edward K. Ream
wrote:
On Sat, Nov 26, 2016 at 12:50 PM, rengel
> wrote:
>
> >
>
> I still don't understand why you are struggling with the newline
> characters at all.
>
> Many thanks for this. You have
On Sun, Nov 27, 2016 at 5:21 AM, rengel wrote:
v._bodyString = '\n'.join(v._import_lines) + '\n'
>
No. It inserts a newline when v._import_lines is [].
EKR
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To
That's the only per-importer change required! The code we have been
discussing appears in the base Importer class. i.finalize_ivars, also in
the base class, will restore trailing newlines like this:
>
> v._bodyString = ''.join[z+'\n' for z in v._import_lines]
>
> This is itself simpler than
On Sat, Nov 26, 2016 at 12:50 PM, rengel
wrote:
>
I still don't understand why you are struggling with the newline characters
at all.
Many thanks for this. You have uncovered a blind spot in my thinking.
So instead of clumsily preserving newlines *that it knows
In short, we are getting to matters of style. Imo, this:
>
>> return [self.lstrip_line(z) for z in lines]
>>
>> is slightly preferable to:
>>
>> return ['\n' if z.isspace() else z.lstrip() for z in lines]
>>
>>
> Furthermore, i.clean_blank_lines() uses i.lstrip_line():
>
> def
On Saturday, November 26, 2016 at 8:04:20 AM UTC-6, Edward K. Ream wrote:
>
> In short, we are getting to matters of style. Imo, this:
>
> return [self.lstrip_line(z) for z in lines]
>
> is slightly preferable to:
>
> return ['\n' if z.isspace() else z.lstrip() for z in lines]
>
>
On Sat, Nov 26, 2016 at 5:40 AM, Edward K. Ream wrote:
> On Friday, November 25, 2016 at 7:59:56 AM UTC-6, rengel wrote:
>
>> Why use two functions, when one suffices?
>>
>> def strip_lws(s):
>>return '\n'.join([z.lstrip() for z in s.splitlines(False)])
>>
>
>
On Saturday, November 26, 2016 at 5:40:22 AM UTC-6, Edward K. Ream wrote:
> Provided all tests pass, it's probably safe to define g.splitLines as:
def splitLines(s):
assert g.isString(s), (repr(s), g.callers())
return s.splitLines()
Oops. The last line must be s.splitlines(True).
On Friday, November 25, 2016 at 7:59:56 AM UTC-6, rengel wrote:
> Why use two functions, when one suffices?
>
> def strip_lws(s):
>return '\n'.join([z.lstrip() for z in s.splitlines(False)])
>
Beautiful. I'm going to make this change today.
The Importer class uses i.lstrip_line() in one
On Saturday, November 12, 2016 at 12:32:55 PM UTC-6, Terry Brown wrote:
>
> That tripped me up too, empty strings are OK if you're using 'not
> s.isspace()'.
>
It works both ways. s.lstrip() can be wrong, wrong, wrong, as this
morning's bug fix in i.check shows.
The new i.lstrip_line helper
On Sat, Nov 12, 2016 at 8:12 PM, Edward K. Ream wrote:
> On Sat, Nov 12, 2016 at 11:10 AM, rengel
> wrote:
>
>>
>> The code 'z.isspace()' fails if a line is completely empty.
>>
>
> Happily, all lines (except possibly the last) end with a
On Sat, Nov 12, 2016 at 11:10 AM, rengel
wrote:
>
> The code 'z.isspace()' fails if a line is completely empty.
>
Happily, all lines (except possibly the last) end with a newline :-)
EKR
--
You received this message because you are subscribed to the Google
That tripped me up too, empty strings are OK if you're using 'not s.isspace()'.
Cheers -Terry
On November 12, 2016 11:10:50 AM CST, rengel
wrote:
>
>
>> Instead of testing:
>>>
>>
>>if not ''.join(lines).strip():
>>
>> the new code now tests:
>>
>> if
> Instead of testing:
>>
>
>if not ''.join(lines).strip():
>
> the new code now tests:
>
> if all([z.isspace() for z in lines]):
>
>
What do you want to accomplish?
The code 'z.isspace()' fails if a line is completely empty. Test:
print(''.isspace()) # Fails
>> print(' '.isspace())
On Friday, November 11, 2016 at 10:46:12 AM UTC-6, Terry Brown wrote:
> As another aspect of this pattern, instead of testing,
> >
> >if ''.join(lines):
> >
> > the new code now tests:
> >
> > if all([z.isspace() for z in lines]):
>
> Those don't seem equivalent
Oops. I meant
On Fri, 11 Nov 2016 08:12:57 -0800 (PST)
"Edward K. Ream" wrote:
> On Thursday, November 10, 2016 at 12:48:28 PM UTC-6, Edward K. Ream
> wrote:
> >
> > Up until today, I have always tested for an empty string using not
> > s.strip(). But Doh, this is an unnecessary stress
On Thursday, November 10, 2016 at 12:48:28 PM UTC-6, Edward K. Ream wrote:
>
> Up until today, I have always tested for an empty string using not
> s.strip(). But Doh, this is an unnecessary stress on the GC.
> `s.isspace()` much faster and more pythonic.
>
As another aspect of this pattern,
Up until today, I have always tested for an empty string using not
s.strip(). But Doh, this is an unnecessary stress on the GC.
`s.isspace()` much faster and more pythonic.
Rev 2de4669c replaces `(id).strip()` with `not id.isspace()` everywhere in
the Import class, removing `not not` in two
21 matches
Mail list logo