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

long URLs are broken into a multi-line string which is hard to copy #73

Open
bartzy opened this issue Feb 23, 2020 · 2 comments
Open

long URLs are broken into a multi-line string which is hard to copy #73

bartzy opened this issue Feb 23, 2020 · 2 comments

Comments

@bartzy
Copy link

bartzy commented Feb 23, 2020

  • PrettyPrinter version: 0.18.0
  • Python version: 3.7.4
  • Operating System: macOS 10.15

Description

long strings such as URLs are currently broken into multiple lines, with each line surrounded by a single quote. This make it really hard to copy the URL, for example. I tried to use width but it didn't do anything.

@max-block
Copy link

I also have the same problem. There are some long strings in my data which I don't want to split on multiplt string. Is it possible to configure pprint not to split long strings?

@asford
Copy link

asford commented Jul 6, 2021

import prettyprinter.pretty_stdlib

@prettyprinter.register_pretty(str)
def pretty_str_custom(v, ctx, *args, **kwargs):
    if v.startswith("http://") or v.startswith("https://"):
        return prettyprinter.prettyprinter.pretty_single_line_str(v, ctx.indent)
    else:
        return prettyprinter.pretty_stdlib.pretty_str(v, ctx)

Now you're stoked.

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

No branches or pull requests

3 participants