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

Console.print is broken #20

Closed
damontallen opened this issue Mar 14, 2020 · 7 comments
Closed

Console.print is broken #20

damontallen opened this issue Mar 14, 2020 · 7 comments

Comments

@damontallen
Copy link

damontallen commented Mar 14, 2020

Screenshot

from rich.console import Console
Console.print("Where there is a [bold cyan]Will[/bold cyan] there [u]is[/u] a [i]way[/i].")
Traceback (most recent call last):
File "", line 1, in
File "/home/damon/src/virtualenv-16.7.6/bun/lib/python3.8/site-packages/rich/console.py", line 740, in print
self.line()
AttributeError: 'str' object has no attribute 'line'

@willmcgugan
Copy link
Collaborator

You need to construct the Console class first.

from rich import Console
console = Console()
console.print("[bold green]It works")

@damontallen
Copy link
Author

OH. I'll try that.

@damontallen
Copy link
Author

damontallen commented Mar 14, 2020

That works. Sorry for the misunderstanding, but there is one more thing.
screenshot
There seems to be an issue with quotes appearing in the string breaking print.
The color always turns green.

@damontallen
Copy link
Author

damontallen commented Mar 14, 2020

console= Console()
console.print("Where there is a [bold cyan]Will[/bold cyan] there [u]is[/u] a [i]way[/i].")
Where there is a Will there is a way.
console.print("Where there is a [bold cyan]Will[/bold cyan] there [u]is[/u] a [i]way[/i].")
Where there is a Will there is a way.
full_path='"5"'
console.print(f"\tThe full data path will be: [blue][bold]\"{full_path}\"[/bold][/blue]")
    The full data path will be: ""5""
console.print(f"\tThe full data path will be: \"[blue][bold]{full_path}[/bold][/blue]\"")
    The full data path will be: ""5""
full_path='5'
console.print(f"\tThe full data path will be: \"[blue][bold]{full_path}[/bold][/blue]\"")
    The full data path will be: "5"

@damontallen
Copy link
Author

damontallen commented Mar 14, 2020

Do you want me you open up a separate issue for this?

@willmcgugan
Copy link
Collaborator

Rich will do some automatic syntax highlighting of things like strings and numbers. If you want to disable that feature, add highlight=False to the print function.

@damontallen
Copy link
Author

Perfect! Thank you for helping me out.

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

2 participants