Skip to content

Conversation

alberth
Copy link

@alberth alberth commented Feb 3, 2020

The column computation function in the documentation had a few problems:

  1. Comment spoke about input parameter, but it's actually text.
  2. Something off-by-one must be happening, as last_cr ends up at the newline character, except at the first line.

With respect to the second item, I hacked a quick test (attached), which also incudes the fixed version.

I tried to make the function as small as possible so I deleted the if statement, so the function now relies on rfind returning -1 if it failed to find a new-line. Not sure if you like that, however it is documented functionality: https://docs.python.org/3/library/stdtypes.html?highlight=str%20rfind#str.rfind so should be quite stable behaviour.

t.py.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant