Python Forum
indents disappearing from output after previewing post
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
indents disappearing from output after previewing post
#1
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)
Quote:If you can't learn to do something well?... Learn to enjoy doing it poorly.
Reply
#2
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?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
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..
Reply
#4
(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.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#5
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.
Reply
#6
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.
Reply
#7
    # 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.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#8
(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.
Quote:If you can't learn to do something well?... Learn to enjoy doing it poorly.
Reply
#9
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.
Reply
#10
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-c...ght=indent
Do i have others permissions to move it to board for others to read?
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error while previewing locked post Kebap 4 6,860 Sep-17-2016, 05:52 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020