Live data from Hacker News

Python Print() and Beyond

josiasdev.best

1–10 of 23 posts

Re: Python Print() and Beyond

#2
> By default, all the values you pass to it are separated by empty strings

I think it's space, not empty string?

------

Another error:

    If we execute that, we notice the text is no more separated by a new line. Let's try that again! But this time, we want it to end by y and move to a new line.

    print("Hello James", end="y\n")
    print("How are you doing", end="\n")
    We get the following output

    Hello Jamesy
    How are you doingy
    Yay it worked !
But your second line in code uses `end="\n"`. It won't print "doingy".

Re: Python Print() and Beyond

#4
> This is because since it's on a single line, it is all buffered (packed) before we get it.

Usually. Depending on the environment. It's probably worth pointing out here that Python isn't controlling that buffering - print could have its own buffer, and it could be read that way, but it doesn't.

And buffering-to-newline is a common behaviour, but not necessarily a guaranteed behaviour. You may still wish to flush after a newline, depending on the platform.

Unless you're in REPL, in which case Python often tells the environment how it would like it to buffer, as part of the readline implementation.

Re: Python Print() and Beyond

#6
post #5

The official docs say the same thing in fewer words: https://docs.python.org/3/library/functions.html#print I definitely recommend the official Python docs. They are well written, and you'll find lots of useful nuggets like this.

I personally wish the official docs got a much heavier weighting in the search engines. I hate receiving crap from w3schools and dev.to over the actual good stuff. Stupid SEO crap, but it's a resume puff piece. I can't blame them for writing it.

It is a good article with some good examples, I just wish these kinds of articles didn't exist.

Re: Python Print() and Beyond

#7
post #5

The official docs say the same thing in fewer words: https://docs.python.org/3/library/functions.html#print I definitely recommend the official Python docs. They are well written, and you'll find lots of useful nuggets like this.

I personally wish the official docs got a much heavier weighting in the search engines. I hate receiving crap from w3schools and dev.to over the actual good stuff. Stupid SEO crap, but it's a resume puff piece. I can't blame them for writing it. It is a good article with some good examples, I just wish these kinds of articles didn't exist.

Don’t forget Tutorialspoint, which in my experience is way more endemic to Python PSL search results than every other SEO crap site. And unlike w3schools, it’s not even useful for a quick glance.

Re: Python Print() and Beyond

#8
I really don't see any value in these sort of half-baked posts full of inaccuracies that contribute to low SNR.

Someone mentioned that it's a resume puff piece, but to me, it does more harm to the person that wrote it than good. It exposes his superficial level of understanding and lack of deep programming knowledge.

Would you hire him based on this? I wouldn't.

To end on a positive note, some advice to the author:

Programming is a field where you can't really hide your skill from people that are better than you. This means that "fake it till you make it" isn't a viable strategy. Embrace precision in your writing and avoid guesswork. If you're guessing about behavior, state so (or better, do research so that you don't have to guess). Ideally, you produce technical posts that go deep, have something to say (about the problem at hand or yourself) and are not mere regurgitations of surface-level knowledge. If you don't have something interesting to say, say nothing.

Re: Python Print() and Beyond

#9
post #7

Earlier quoted context omitted.

I personally wish the official docs got a much heavier weighting in the search engines. I hate receiving crap from w3schools and dev.to over the actual good stuff. Stupid SEO crap, but it's a resume puff piece. I can't blame them for writing it. It is a good article with some good examples, I just wish these kinds of articles didn't exist.

Don’t forget Tutorialspoint, which in my experience is way more endemic to Python PSL search results than every other SEO crap site. And unlike w3schools, it’s not even useful for a quick glance.

On rare occasions they'll rank for a concept that I need, but don't know exists. Things like the SAX pattern for XML. Which is somewhat useful.

Re: Python Print() and Beyond

#10

I really don't see any value in these sort of half-baked posts full of inaccuracies that contribute to low SNR. Someone mentioned that it's a resume puff piece, but to me, it does more harm to the person that wrote it than good. It exposes his superficial level of understanding and lack of deep programming knowledge. Would you hire him based on this? I wouldn't. To end on a positive note, some advice to the author: P…

> Programming is a field where you can't really hide your skill from people that are better than you.

You're not wrong, but one rarely needs to impress a person better than me to get a job. Hiring managers are rarely subject-matter experts.

Post reply on HN