@Crackerfracks My comment is 7 years old. I know what you're saying and I don't speak like that anymore unless I want to vent frustration in private. Best wishes.
WIoHu, if you're going to critique something because it's 'not good for beginners', your explanation should meet a basic level of quality, your tone should have a modicum of respectfulness to it, and I SHOULD BE ABLE TO UNDERSTAND THE ISSUE AS A BEGINNER.
I know I'm years and years after the fact, but this crap just made me feel bad about what I learned (on my own, not from this person's solution).
If you really cared about beginners, you would 1) use language that was easy for beginners to understand, and focus more on explaining exactly where and why the other person's code is 'bad', 2) approach it with a clear intent to educate and not denegrate, and 3) when you had to clarify something, take the time to disambiguate the good solution vs the bad solution.
Otherwise you're not doing it to help beginners. You're doing it to feel a sense of superiority over others because you've learned something they haven't yet.
It's bloodsport.
I would write here reply on your old question, just to make a note on my understanding of join statement work.
Databases are usually working with various data having certain characteristics based on which data could be filtered or sorted.
If you have two independent sets of data you have to allign certain elements from one set with certain elements from another set.
I.e. you do something like: for each element from set 1 find elements in set 2.
In your particular case your request is: For each element in table posts find 2 elements in table categories where id's are equal.
we took first post, take it category and search for it in table categories, obviouisly your limit statement does not make any sence as soon as for each element form posts table always exists only one record in categories ...
well, most of times we call some functions without knowing how it's done inside the blackbox, that is abstraction. it is a fact that is not readable but you would not need to read that.
@Crackerfracks My comment is 7 years old. I know what you're saying and I don't speak like that anymore unless I want to vent frustration in private. Best wishes.
WIoHu, if you're going to critique something because it's 'not good for beginners', your explanation should meet a basic level of quality, your tone should have a modicum of respectfulness to it, and I SHOULD BE ABLE TO UNDERSTAND THE ISSUE AS A BEGINNER.
I know I'm years and years after the fact, but this crap just made me feel bad about what I learned (on my own, not from this person's solution).
If you really cared about beginners, you would 1) use language that was easy for beginners to understand, and focus more on explaining exactly where and why the other person's code is 'bad', 2) approach it with a clear intent to educate and not denegrate, and 3) when you had to clarify something, take the time to disambiguate the good solution vs the bad solution.
Otherwise you're not doing it to help beginners. You're doing it to feel a sense of superiority over others because you've learned something they haven't yet.
It's bloodsport.
RU
Я так не думаю. 2 раза пробегать по длинному списку это плохо.
Супер!
I would write here reply on your old question, just to make a note on my understanding of join statement work.
Databases are usually working with various data having certain characteristics based on which data could be filtered or sorted.
If you have two independent sets of data you have to allign certain elements from one set with certain elements from another set.
I.e. you do something like: for each element from set 1 find elements in set 2.
In your particular case your request is: For each element in table posts find 2 elements in table categories where id's are equal.
we took first post, take it category and search for it in table categories, obviouisly your limit statement does not make any sence as soon as for each element form posts table always exists only one record in categories ...
I think its pretty readble to me.
Stop writing one line! It is not readable
well, most of times we call some functions without knowing how it's done inside the blackbox, that is abstraction. it is a fact that is not readable but you would not need to read that.
Unreadable. I wish code like this would not get upvoted so much. This is not best practice.
Please stop arguing guys. All those solutions are bad, yours and mine too. We parse twice the array while it would be so easy with only one pass.
@WloHu list comprehension is an important thing to learn for python newbies. And your solution actualy IS shit
lol
This comment is hidden because it contains spoiler information about the solution