When you surround something in single quotes, for example:
print(‘Hello world’)
the website replaces the normal single-quote ascii character with some fancy characters ‘ and ’.
This can cause issues when copying and pasting code, because those literals are not going to be recognized. For example if I copy the above into python I’m going to get the following error:
>>> print(‘Hello world’)
File "<stdin>", line 1
print(‘Hello world’)
^
SyntaxError: invalid character in identifier
These should be removed to avoid confusing users in the future.
Hi @sagendor - thanks for pointing this out. Did you notice this in the MATLAB guide? That’s the only place I’ve found single quotes in code, but I want to be sure they all get fixed.
I imagine it will be a fairly common use case for someone to type something like:
“Hey, try this: <<some code containing single quotes>>”
In those cases if you don’t happen to notice that the quote characters aren’t the actually ASCII quotes, you’ll get error messages that may be confusing if you aren’t anticipating it.
Ah, I thought you were saying this happens on our website, not the user forum. Yes, I can see this issue in some of the post replies. We’ll see if we can change this, although I’m not sure if Discourse will allow for customization like that.
A guideline for posting code on Discourse: Use the pre-formatted text button in the toolbar (</>) to enclose your code to avoid issues with formatting of quotes.