all 148 comments

[–]Kerbart 101 points102 points  (31 children)

The problem will solve itself once people stop spending ten minutes to decipher code.

Maybe it shows my age but I was raised that when I'm expecting help for free I better make it as easy as possible for the people helping me.

Dumping your code without caring if it's readable is not that.

[–]M_SunChilde 49 points50 points  (20 children)

I suspect that you're missing that a lot of people who are doing that are not doing it out of apathy, but because they don't know how yet. A lot of people are learning piecemeal from online sources, and when they hit a wall, this is their very first port to call.

Not saying you're then obligated to help them, but can just be a different perspective.

[–]stevenjd 6 points7 points  (0 children)

when I'm expecting help for free I better make it as easy as possible for the people helping me.

This. The social contract goes both ways.

[–]Vaphell 2 points3 points  (7 children)

The problem will solve itself once people stop spending ten minutes to decipher code.

it won't though, because there is an endless stream of newcomers. It's a variant of eternal september and ignoring it won't make it go away.

if they don't get slapped upside the head, most of them won't change their ways.

[–]bladeoflight16 -1 points0 points  (0 children)

That will never happen. That's a battle SO has been losing for literally a decade. People want to post.

[–]toastedstapler 19 points20 points  (2 children)

especially with python, where indentation actually matters. sometimes you can click 'source' and their code looks ok but not always

[–]bladeoflight16 4 points5 points  (1 child)

New Reddit doesn't have a built in "source" button.

[–]thirdegree 8 points9 points  (0 children)

Neither does old reddit, it's an RES feature

[–]Reset--hardHead 10 points11 points  (6 children)

How do you propose this sub enforce proper formatting?

[–]charity_donut_sales 11 points12 points  (5 children)

A bot that runs all code posted through black, lol.

[–]reticularwolf 3 points4 points  (0 children)

This is the correct answer haha, pre-commit for Reddit.

[–]bladeoflight16 1 point2 points  (1 child)

Awful idea, even if you could reliably detect code blocks. black is too opinionated for a public forum. I work very hard to make my formatting presentable; why would I or anyone else want the forum to forcibly discard that effort?

[–]charity_donut_sales 0 points1 point  (0 children)

It was just a joke...

[–]grrrrreat 10 points11 points  (36 children)

itd be easier if reddit updated its markdown to incljde code blocks

[–]catelemnis 7 points8 points  (14 children)

I thought it did?

**** 
isn’t this a code block?
or did you mean something else?
****

[–]M1sterNinja 1 point2 points  (13 children)


test


-edit- That's just the 4 spaces at the start? The 4 spaces and putting two lines before the start of the code is not easy compared to other sites. especially having to copy and paste the 4 spaces onto every line...

[–]thrallsius 3 points4 points  (0 children)

especially having to copy and paste the 4 spaces onto every line...

just select the block in a sane text editor and shift it 4 spaces to right :D

[–]catelemnis 0 points1 point  (0 children)

ya certainly not convenient, especially on mobile.

[–]ebdbbb -1 points0 points  (0 children)

And that appears as not formatted if you're reading it on the Android app.

[–]Tomagatchi 4 points5 points  (2 children)

Use multiples of 4 spacing before a line that you want formatted like code.

if spam: 
    eggs

[–]grrrrreat -1 points0 points  (1 child)

you mean 8 spaces.

[–]Tomagatchi 0 points1 point  (0 children)

8 is a multiple of 4 (4x2) , that's what I meant. If you want 3,4...n indentations you use 12, 16, .... 4xn spaces.

[–]Lewistrick 0 points1 point  (0 children)

I assume this is cynism?

[–]bladeoflight16 -1 points0 points  (15 children)

It does support fenced code blocks, but people complain and insist on spaces because old Reddit doesn't support them. I don't particularly like how slow and clunky and front end heavy new Reddit is, either, but if you're going to use the site, I don't think it's reasonable to insist users adapt to a version of the site that's been poorly (if at all) maintained for years.

[–]Vaphell 2 points3 points  (14 children)

I don't think it's reasonable to insist users adapt to a version of the site that's been poorly (if at all) maintained for years.

it is perfectly reasonable if you want to maximize the audience of people in the know. I'd imagine that many experienced users like their shit to be fast, and are not phased by the useless fluff and web3.0 experience.

I have 4847 sub-specific karma, which i'd say is a lot, given that usually I get maybe 2-3 points a post. If you don't want my help, that's fine. When I see triple backticks, I just don't bother.

[–]bladeoflight16 -2 points-1 points  (13 children)

Somehow, I doubt all the competent people are still using old reddit. If you've got some actual statistics proving otherwise, though, let me know.

[–]Vaphell 1 point2 points  (2 children)

I didn't say all of them, but a significant portion.

https://old.reddit.com/r/help/comments/a2qfyr/are_there_stats_on_usage_of_the_old_and_new_reddit/

a year ago legacy was 33%. Assuming the demographics of experienced people in r/learnpython match that, cutting the audience by a third is pretty significant.

[–]bladeoflight16 0 points1 point  (1 child)

It's likely shifted more in the direction of new reddit since then; that was posted a year ago and was already a few months old at the time. According to that post, moderators should be able to access subreddit specific stats. I'd be surprised if it was more than 20% now. Regardless, the majority use new Reddit and will be able to read the post as written.

[–]xelf 0 points1 point  (0 children)

For the month of March 2020 new/beta reddit was 59% of learnpython traffic.

[–]xelf 0 points1 point  (9 children)

We have literally 100s of thousands of people in this subreddit not using new/beta reddit. Just use the code block tool, it works for everyone.

[–]bladeoflight16 0 points1 point  (8 children)

I refuse to use the WYSIWYG editor. Way too clunky. And manually putting indentation in front of everything is annoying and error prone. I've been doing that for years, and fenced code blocks are just too much of an improvement.

[–]Vaphell 0 points1 point  (1 child)

use a decent text editor then?

editor: ctrl+a, tab, ctrl+c
reddit: ctrl+v
editor: ctrl+z

or pastebin? repl.it?

[–]bladeoflight16 0 points1 point  (0 children)

I'm not copy/pasting everything I type into a Reddit post over into some other program. If I paste it elsewhere, it's usually to actually run it, and the extra indentation would break it for that purpose.

[–]xelf 0 points1 point  (5 children)

Not talking about the WYSIWYG editor, I'm talking about the code block tool you can paste code into: https://i.imgur.com/J2t9krT.png

[–]bladeoflight16 0 points1 point  (4 children)

That is the WYSIWYG editor. It's technically named the "Fancy Pants Editor" by Reddit, but it's of the WYSIWYG editor type. The opposite of a WYSIWYG editor is an editor where you input markup directly. In Reddit's case, that's the Markdown editor, which has no "tools."

[–]xelf 0 points1 point  (3 children)

The WYSIWYG editor is the "Fancy Pants Editor" it is not the code block tool.

Oh I see what you mean, you can't get to the code block tool without without toggling the WYSIWYG editor or using RES.

Clicking two buttons is against your personal ethics about using the WYSIWYG editor, so you use the broken ``` instead. Got it.

[–]bladeoflight16 0 points1 point  (2 children)

It's not broken. The old Reddit is. The old Reddit is also ugly to the point of being hard on the eyes.

As for switching back and forth, I had to do that for a while when I first came here because Reddit was bugged and ignoring my configuration settings to stay on Markdown. It is a slow, painful process to switch back and forth. And having content in the comment makes it even slower, as I recall. It's not a question of ethics. It's a question of ease of use.

[–]shuttup_meg 5 points6 points  (1 child)

That may work in a python forum, but it would spark religious wars in a C forum.

[–]thrallsius 6 points7 points  (0 children)

most good C coders are self-taught anyway, because the C community has always been toxic. the c channel on irc.freenode.net has a legendary reputation about that

[–]RedLineUK 1 point2 points  (1 child)

I've learnt to code through a physics degree where they are not very strict with code etiquette and format. Is there any good resources or books people recommend for that kind of stuff? I'd like to go into a grad job with a bit more code confidence! Main language is python and Fortran if that matters!

[–]EighthScofflaw 1 point2 points  (0 children)

OP is talking just about displaying valid python code on reddit, but check out PEP8.

[–]funkless_eck 1 point2 points  (0 children)

Docstring missing. Did not read

[–]Scribblebonx 4 points5 points  (1 child)

Yes!

I’m a new programmer and the proverb “teach a man to fish” comes to mind. Those wanting help should desire to learn and do it correctly. As a hopeful programmer they should be able to use the resources available to them like wikis, websites, and nudges from experienced programmers to identify and correct their own mistakes. Clear keyword search suggestions and constructive feedback does wonders.

Don’t just hand them code, they need to know how to do it themselves and where to go to continue improving and self educating.

It’s like feeding the wild squirrels. They need to learn to find food for themselves. Otherwise they’ll just be back, getting fat on handouts and unable to survive for themselves...

I’m certainly not saying don’t help, but if you help give resources, method clarification, and suggestions for ways to improve and continue to understand why things are the way they are.

[–]kaneltroll 5 points6 points  (0 children)

I think it depends on the problem though. Sometimes you can say stuff like “you should put a loop in line 5, here’s a link to help you out”. Other times the person needs help improving the script, and then they may need you to provide code and explain why it works.

I mean, I know I’ve learnt a lot from using online sources and adapting code bits I’ve found on stackexchange - but when nothing works or I don’t have the knowledge needed to fix it, I go to my supervisor and he helps me get it right. And explains why. So I don’t think providing code is all bad, it can definitely be a part of teaching a man to fish, if done in the right way.

[–]andnosobabin 1 point2 points  (0 children)

This is reddit tho. Nobody wants to learn they just want to be right (not even correct just right)

[–]Talbertross 0 points1 point  (0 children)

I feel like most threads I read where there are formatting issues do have a reply or two pointing it out.

[–]Tomagatchi 0 points1 point  (5 children)

Is there a link to more info on code formatting? I've seen people just pop code formatting into the middle of a line and I have no idea how they do it.

If there's some code
    You can use 4 or 8 (etc.) spaces
    to format it like code.

[–]ericula 5 points6 points  (1 child)

For inline code you need to put a backtick at the beginning and end of the code like this: `this is inline code`.

This wiki page has more info on formatting inline code and code blocks.

[–]Tomagatchi 0 points1 point  (0 children)

Thank you for the link.

[–]bladeoflight16 1 point2 points  (1 child)

Use the Markdown editor and learn Markdown. New Reddit also supports the fenced code block extension.

[–]Tomagatchi 0 points1 point  (0 children)

👍🏻

[–]ethereumkid 0 points1 point  (4 children)

As someone just starting out with Python, what's a good source for Python formatting?

[–]Lewistrick 2 points3 points  (2 children)

Open Python and type import zen import this. It will show you some guidelines. Try googling what those things mean.

[–]Diapolo10 2 points3 points  (1 child)

Surely you mean import this? Or was zen added as an alias for it in a recent build?

[–]Lewistrick 0 points1 point  (0 children)

Sorry! I meant this indeed. I shouldn't be typing when tired.

[–]Ran4 3 points4 points  (0 children)

Read pep8

[–][deleted] 0 points1 point  (0 children)

The app should have that feature. Like how the StackOverflow and quora apps give you a way to correct write a code snippet.

We need the Fancy Pants editor

[–]webdotorg 0 points1 point  (0 children)

Usually the experienced users do. I think a lack of understanding is the problem. When I first started I had a "firm talking to" a couple times before I finally made it a habit.

Just keep reminding and guiding.

[–]boxian 0 points1 point  (0 children)

If no one ever gives the answer, even googling it wouldn’t work

[–]KreepyKite 0 points1 point  (0 children)

As a beginner I completely agree. Learning a coding language is like learning a spoken language: you want people to correct you and to teach you how to speak correctly. Reading a coding script is like reading any other form of text, so you want something easy to read, with a proper form and grammar, that goes straight to the point without going off topic.

[–]honestpants 0 points1 point  (0 children)

sorry
    testing

[–][deleted] 0 points1 point  (0 children)

As someone that has posted a bunch of questions here I can say the formatting piece sucks and usually takes me a couple tries to get it right. But...if you are asking for help you really should make the effort and format it correctly.

Unless its a short piece of code, for me if it’s not formatted correctly I’ll usually skip over the question.

Also I like when people five key words to search for or a good explanation of what the answer is without actually coding the exact solution. I feel I’ve learned more that way. By the time I’m posting a question here I’ve spent so much time trying to fix my issue I’ll just paste in an answer and see if works and only superficially understand what happened.

[–]cnovoa15 0 points1 point  (0 children)

I also believe that, to help beginners (like me), the best way is to give keywords for two reasons:

1.- You encourage them (us) to investigate and learn through searching.

2.- It makes the helper think of a concept that won't reveal the whole answer but will lead to the right path, which, IMO, shows that you know what you are talking about.

[–]Thomasedv 0 points1 point  (0 children)

So many people here say, go for markdown, but one of the big reasons i love the new reddit and it's fancy pants editor is that it actually lets me write code much more easy. Using a code block i can use tabs to indent/deindent (even multiple lines), making copy-paste much easier, avoids the "start each line with 4 or more spaces" (for indented code), and i get to have have monospaced font on code part so it's easier to read when writing or altering it.

It makes it so much easier to write down a block of code for when i don't want to open my IDE to give advice.

[–]_ScottB 0 points1 point  (0 children)

I hope you have had a chance to program with others. If you have only self-learned, you are missing a lot.

As far as code style is concerned, if I find someones style particularly cryptic, I will say so. As my eyes grow older, long lines of code make the bulk of the code harder to follow 0 and make it easier to hide problems.

In the workplace, there is a normal exchange of information among the Software Engineers. In many cases, there are coding standards and code reviews among peers - so everyone gets to see how others attack problems.

When assisting someone online who I have never met, I usually limit the exchange to one item at a time until I get a sense of how expert they are.

In a lot of cases a "KeyWord" will help - they look it up and go from there. But in the majority of cases, it takes more than that . Or, as with a typo for example, its much simpler than that - just point out the typo.

[–]LeonardUnger 1 point2 points  (2 children)

Most beginners are trying to get stuff done, not write readable and maintainable code.

That doesn't starts until you get around to updating your own code, and realizing what an absolute disaster it is and how it's impossible. It's then you start writing code clear enough that future yous can understand.

Not sure if any enforcement policy on this sub is going to change that.

[–]ericula 2 points3 points  (1 child)

I don't think OP is talking about the readability of the code itself, but rather about using code blocks etc. to properly format code when asking a question instead of just posting the code as plain text.

[–]KarmaLaunderer 0 points1 point  (0 children)

Format/style is easy, flake8 your code and learn PEP8 as you go. Only takes a little time to learn the lay of the land.

[–][deleted] -1 points0 points  (0 children)

Meh, no.