Open AkkiDinosaur opened 1 year ago
Hey @AkkiDinosaur, thanks for reporting. Unfortunately, I can't reproduce this problem on Linux, as can be seen in the screenshot below:
@dalthviz, could you check if you get this problem on Windows?
@ccordoba12 I was able to reproduce this. Seems like if you have a number character before the tab character the print function uses a space instead of a tab?:
Also, I was able to reproduce this on QtConsole but not on IPython:
Could it be that your state
and postcode
variables contain numeric characters @AkkiDinosaur ?
Ok, thanks @dalthviz for the check.
@AkkiDinosaur, we'll try to solve this problem in the second half of the year. But please don't hold your breath because we have a ton of other things to do and this is not critical.
Isn't this exactly how \t is supposed to work? Tab isn't "spacebar but bigger". Citing wikipedia:
The tab key is used to advance the cursor to the next tab stop.
This behavior is also consistent between a regular python repl:
Python 3.9.16 (main, Dec 7 2022, 01:11:51)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("a\ta")
a a
>>> print("aa\ta")
aa a
>>> print("aaa\ta")
aaa a
>>>
IPython:
Python 3.9.16 (main, Dec 7 2022, 01:11:51)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.7.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: print("a\ta")
a a
In [2]: print("aa\ta")
aa a
In [3]: print("aaa\ta")
aaa a
And qtconsole:
Jupyter QtConsole 5.4.0
Python 3.9.16 (main, Dec 7 2022, 01:11:51)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.7.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: print("a\ta")
a a
In [2]: print("aa\ta")
aa a
In [3]: print("aaa\ta")
aaa a
But in the example @dalthviz posted above:
print('123\t456')
there are clearly different results between Qtconsole (which is embedded in Spyder) and terminal IPython. So, is that not a bug?
Well, it looks like the tab width in Qtconsole is 4 while it is 8 in IPython. Not sure I would consider that a bug.
The changelog for Qtconsole 4.4.0 mentions changing the default tab width to 4. Though, I can't find a way to set it to something else, for either Qtconsole or IPython.
Just in case, gave this a check again and seems to me that @bessman is right! So checking something like:
def print_test():
print("a\ta")
print("1\t1")
print("aa\ta")
print("11\t1")
print("aaa\ta")
print("111\t1")
print("aaaa\ta")
print("1111\t1")
You get over QtConsole and IPython the following:
And indeed the only variation there is that QtConsole takes 4 spaces for the tab and IPython takes 8. Also, is true that seems like the is no way to configure this behavior (at least I don't see any config available for that over the docs: https://qtconsole.readthedocs.io/en/stable/config_options.html). The value seems like is defined here: https://github.com/jupyter/qtconsole/blob/a72387f01dea2076346ecb38857de5266414dbe6/qtconsole/console_widget.py#L298
Maybe making that _tab_width
a traitlet variable to allow its config via the CLI could be worthy?
Maybe making that _tab_width a traitlet variable to allow its config via the CLI could be worthy?
I don't think that would be enough to solve this problem because people would need to know that that setting exists and adjust it to make things work as in a system terminal.
Since the _tab_width
change from 8 to 4 was done in PR https://github.com/jupyter/qtconsole/pull/250 to add indent/dedent of code when working in a prompt, I think we should have two _tab_widths
: one for editing code and one for outputs.
So, @dalthviz please review that could be done in Qtconsole's code. My guess is that _tab_width = 4
is only used in the ConsoleWidget._indent
method, and if that's the case, we can use that value there and restore self._tab_width = 8
for outputs.
Description
What steps will reproduce the problem?
print("Please provide your address.") street = input("Street: ") suburb = input("Suburb: ") state = input("State: ") postcode = input("Postcode: ")
print() print(street + " " + suburb + "\n" + state + "\t" + postcode)
this code outputs and ignores \t, printing a regular space instead.
Versions
Dependencies