How to upload a .py or .txt file?

The create topic editor allows drag/drop of graphics images. Why not allow drag/drop of .py & .txt script files?

Having user copy/paste text, then manually indent each line by 4 spaces is rather annoying.

You don’t have to manually indent each line by hand.

If you are using the fancy editor, you can use the “format as code”
button which I believe looks like this: </>

Otherwise you can begin and end your code blocks with three backticks,
like this:

code goes here

Note that the backticks have to be on their own lines.

I’m a bit surprised that the Markdown code block syntax is unknown to lots of Discourse users.

For a reason unknown to me, indentation is mangled in many posts even inside the code blocks, like in the following posts:

There are also cases where only part of the code is included in the block, or only part of the block is in fixed-width font, or a nested quote level appears for each level of indentation, e.g.:

I have no idea why all this is happening. I’ve just activated mailing list mode for my account and will be trying to reply by email to something with a few tests to see if it is related to email (or maybe someone knows?).

At any rate, when a solution is found, it might be worth adding on the pinned post to tell users not to send screenshots but complete code examples, and how to format it correctly.

Thanks Steve. It looks like the backticks may not be documented anywhere in the mouse hover help. The </> icon inserts instructions:

indent preformatted text by 4 spaces

Other minor note: forums allow drag/drop of graphics & .txt files.

So for .py, copy rename as .txt, then drop into post editor.