Python Forum
indents disappearing from output after previewing post - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html)
+--- Forum: Board (https://python-forum.io/forum-26.html)
+--- Thread: indents disappearing from output after previewing post (/thread-4058.html)

Pages: 1 2


indents disappearing from output after previewing post - Crackity - Jul-20-2017

Hello,

I noticed this issue yesterday during another post and a moderator suggested I post this here to let someone know.
I was having trouble with getting my output to match my example in my book. I figured it must've been something I was missing, but then I noticed that the indents in my output would disappear after previewing my post.

Here is an example before previewing my post:

Output:
Copy Sort... Array : [5, 3, 1, 2, 6, 4] Removing value 1 from [5, 3, 1, 2, 6, 4] Removing value 2 from [5, 3, 2, 6, 4] Removing value 3 from [5, 3, 6, 4] Removing value 4 from [5, 6, 4] Removing value 5 from [5, 6] Removing value 6 from [6] Copy : [1, 2, 3, 4, 5, 6] Array : [5, 3, 1, 2, 6, 4] >>>
and here is what it looks like after previewing:
Output:
Copy Sort... Array : [5, 3, 1, 2, 6, 4] Removing value 1 from [5, 3, 1, 2, 6, 4] Removing value 2 from [5, 3, 2, 6, 4] Removing value 3 from [5, 3, 6, 4] Removing value 4 from [5, 6, 4] Removing value 5 from [5, 6] Removing value 6 from [6] Copy : [1, 2, 3, 4, 5, 6] Array : [5, 3, 1, 2, 6, 4] >>>
For some reason when I preview my post it removes the indent from my output, it really threw me off at first because I didn't catch it the first couple of times that it did it.

Because I saw this question asked in other posts while looking to see if this issue had already been reported I am running:

Windows 7 home edition
Google chrome, Version 59.0.3071.115 (Official Build) (64-bit)


RE: indents disappearing from output after previewing post - sparkz_alot - Jul-20-2017

A couple of questions to help clarify.

1) Does this happen every time?
2) What are you using to write your code? (i.e.: Notepad, Pycharm, Vim, etc.)
3) How are you copying your code?
4) How are you pasting your code?


RE: indents disappearing from output after previewing post - MTVDNA - Jul-23-2017

I have noticed this same issue. As far as I know it happens every time. I copied my code from the console, I don't really see how the editor is relevant. (I used repl.it for some post I made here)

Copied and pasted using ctrl + c, ctrl +v. The output as pasted looks just fine in the editor until you press the preview post button. The actual preview will look fine but the text in the editor is then changed already. For some reason the first indentation (tab/space) is removed the first time you preview that bit of output... If you preview again, it doesn't change anymore.

If you copy from the forum's editor and paste in it again, nothing changes. If you copy from somewhere else, it does change. It's really weird, because in the editor they look exactly the same.

Typed in editor:
Output:
0  1   2    3
Copy/pasted from editor:
Output:
0  1   2    3
Copy/pasted from console with 1 preview:
Output:
0 1  2   3
Copy pasted from console without preview:
Output:
0 1 2 3
Something about pasting in this editor is weird. Sometimes when I past it puts color tags around the output, other times it won't. At one point it only put color tags around the first and last character of the output and the output tags itself... Haven't been able to replicate exactly how that works though..


RE: indents disappearing from output after previewing post - sparkz_alot - Jul-24-2017

(Jul-23-2017, 11:45 PM)MTVDNA Wrote: I don't really see how the editor is relevant.

Some IDE's and text editors include formatting. The code posted between code tags cannot contain them. When posting, try using the key combination "Ctrl + Shift + V" (removes any formatting) to paste. In your code, do not mix tabs and spaces. Python uses spaces, this may also cause problems when posting.

The more information you can supply, the more likely it will be responded to by the admins.


RE: indents disappearing from output after previewing post - MTVDNA - Jul-24-2017

As far as I can tell no formatting is included (when I use view source in the editor). Pasting with ctrl + shift + v makes no difference either.

Also, it seems that although only 1 space is removed when previewing, all tabs are removed:

Pasted using ctrl + v, 1 preview:
def get_protnumber2(prefix):
l = []
for attribute in dir(socket):
if attribute.startswith(prefix):
key = getattr(socket, attribute)
value = attribute

l.append((key,value))

return dict(l)
Pasted using ctrl + shift + v, 1 preview:
def get_protnumber2(prefix):
l = []
for attribute in dir(socket):
if attribute.startswith(prefix):
key = getattr(socket, attribute)
value = attribute

l.append((key,value))

return dict(l)
Pasted without preview:
def get_protnumber2(prefix):
	l = []
	for attribute in dir(socket):
		if attribute.startswith(prefix):
			key = getattr(socket, attribute)
			value = attribute
			
			l.append((key,value))
			
	return dict(l)
Edit:
apparently this is the exact same issue that was being discussed in this thread.


RE: indents disappearing from output after previewing post - Larz60+ - Jul-24-2017

a while back, I saw something of this sort when switching between 'view source'
and the editor. But I haven't seen that in quite some time.


RE: indents disappearing from output after previewing post - DeaD_EyE - Jul-24-2017

    # 4 whitespace
After editing this post, I'll get 3 whitespace.

Edited: Hm still 4 whitespaces.
Edited via QuickEdit: But I have sometimes this issue.
Edited: In the rendered view, I get 3 Whitespaces. But the source is still 4.


RE: indents disappearing from output after previewing post - Crackity - Jul-24-2017

(Jul-20-2017, 12:53 PM)sparkz_alot Wrote: A couple of questions to help clarify.

1) Does this happen every time?

I've only just recenly noticed it, but yes it seems to do it for me every time.

2) What are you using to write your code? (i.e.: Notepad, Pycharm, Vim, etc.)

Python 3.6.1 IDLE

3) How are you copying your code?

Cntl C

4) How are you pasting your code?

Cntl V between the python code input/output (depending on what I'm pasting) brackets as I was chided for not doing on my very first post.

P.S. Something else I just checked to confirm, but this appears to only be affecting my output results, not my input if that helps.


RE: indents disappearing from output after previewing post - snippsat - Jul-24-2017

This is a MyBB(all forum has it) problem that we haven't been able to fix.
Will always lose 1-indent from Quick Reply when clicking Preview Post button.
So post code in Preview Post is advisable,but will work anyhow with 1-less indent.


RE: indents disappearing from output after previewing post - metulburr - Jul-24-2017

Quote:This is a MyBB(all forum has it) problem that we haven't been able to fix.
Will always lose 1-indent from Quick Reply when clicking Preview Post button.
So post code in Preview Post is advisable,but will work anyhow with 1-less indent.
i still havent heard anything about this problem from the MyBB Staff. I bumped the problem post though. I suspect that they have this occur, but do not see it as much as we do because of whitespace being so important in Python. So other coding forums would be viewed as a minor problem and non-coding forums probably wouldn't catch it at all.

@OP
The only way currently to fix it is to remove the quick reply box and force advanced reply only. Which we probably wont do. I would advise for the time being, until this problem is resolved, to post in the quick reply editor things like one-liner responses and keep source code and complex responses to the advanced reply editor. This will bypass the issue.

Found the thread pertaining to this situation. However it is in the admin/mod section
https://python-forum.io/Thread-strange-change-of-the-indention-to-3-spaces?highlight=indent
Do i have others permissions to move it to board for others to read?