3 ms·
I get it, this is supposed to more usable than Stack Overflow, where pedantic discussions can obstruct usability by occluding the simple Q&A. But right away I s
by boltzmannbrain 6y ago
I get it, this is supposed to more usable than Stack Overflow, where pedantic discussions can obstruct usability by occluding the simple Q&A. But right away I see the simplicity of "How to X with Y" yields solutions that are not entirely correct (which is different from incorrect). For example, the current solution for reading a file in Python is unsafe, yet there is no way of seeing how or why; sure it works, but it also proliferates dirty code.
- alex_portabella 6y agoTotally agree with you. The idea is that you can have multiple examples per language, the highest upvoted one is displayed first, then you can page through the others. You can also comment on examples. But yes, care needs to be taken for sure.
- why_only_15 6y agoWhy is the python one unsafe? Lack of with-block?
- riezebos 6y agoWhen I look at the website I currently only see "No items", but if you are using Python 3.6+ the pathlib[0] library has a very nice way of reading/writing files: from pathlib import Path p = Path("my_file.txt") p.write_text("thing that needs to go into a file") [0]https://docs.python.org/3/library/pathlib.html#pathlib.Path.write_text https://docs.python.org/3/library/pathlib.html#pathlib.Path....
- alex_portabella 6y agoIt seems up to me https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d64522fdd5d https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d645... That's the "Write to a file" item, I can see two Python examples there.
- riezebos 6y agoAh, this morning when I went to the site it only showed "No more items" no matter what I did. Now it shows "No more items" for 2 seconds and then starts showing items. I think the first example is what another commenter meant as unsafe. My example is under the hood doing exactly what the second (safe) example is doing, but without the need to use the context manager yourself.