Comment

Comment by 1024core

I was writing some Python code (not my primary language), and wanted to know if there was something built into f-strings that would nicely wordwrap the output.

I did a Google search for "how can I create f-strings in python so the output is wrapped at some fixed length". Except, for Google, I did not use the "how do I" etc. and just threw some keywords at it: "python f-string wrapping", "python f-string folding", etc.

All I got back was various results on how to wrap f-strings themselves.

Frustrated, I typed "how can I create f-strings in python so the output is wrapped at some fixed length" into ChatGPT, and back came the answer: ... However, f-strings themselves don't provide a built-in method for wrapping text at a specific width. ... For text wrapping, you can use the textwrap module ... Here's how you can combine f-strings with the textwrap module to achieve text wrapping: ... (followed by a full example).

I think "Search" will be changing dramatically over the next year or two. And websites which depend on Search traffic to survive will be in deep trouble.

parent 1024core 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton