Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column computation in documentation #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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