Live data from Hacker News

Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

github.com

41–50 of 78 posts

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#41

Can someone help me understand the rationale behind semantic whitespace as a replacement for explicit delimiters? Is it purely aesthetic?

If you haven't read Landin's "The Next 700 Programming Languages", you should. I don't know if it's still outside the ACM paywall, but you'll find it in a web search if not. It introduced the offside rule -- not actually what Python has -- inspired by mathematical notation. Note "it can be mixed freely with [...] punctuation" (e.g. Haskell). The paper talks about "physical representations", relevant to syntax highlighting mentioned below (or "fontification" in Emacs, reminiscent of typefaces in the publication language of ALGOL).

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#42
It's a shame Python doesn't natively support easy invocation from command line. It really shoots down a whole class of applications where bash is getting used but Python would be so much better.

I've ended up using Groovy for this level of scripting, and it works really well.

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#43

Can someone help me understand the rationale behind semantic whitespace as a replacement for explicit delimiters? Is it purely aesthetic?

Your friends are going to insist on properly indented code no matter what your compiler/interpreter wants, so rather than following one set of rules for your friends and a different set of rules for your compiler, why not teach the compiler to think like your friends so that you only have one set of rules to think about?

I'd call it pragmatic.

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#44

Earlier quoted context omitted.

It forces consistent formatting within a file. But I think it was more relevant years ago. These days I see a lot of people using code formatters.

I still think one of Go’s best contributions was formatting with ‘go fmt’. It’s refreshing to see so many language communities just embrace a format on save standard and keep it moving. Reading Python has always been a bit of a headache for me, but that probably has as much to do with the lack of type annotations as it does the lack of braces.

Auto formatters are the future, why should humans ever have to manually format or discuss how it should look ever again.

However, languages that have a line length limit are the blight of them. There isn't a python formatter that won't make everything mush. My if clause that is 81 chars wide doesn't need to be broken up. Similar, my strings don't need to be reflowed.

Go fmt ignores line length, and always produces a formatted file that is pretty as a result.

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#47
post #42

It's a shame Python doesn't natively support easy invocation from command line. It really shoots down a whole class of applications where bash is getting used but Python would be so much better. I've ended up using Groovy for this level of scripting, and it works really well.

It doesn't? If I write this into a file (/tmp/test.py):

    #!/usr/bin/env python
    
    print("Hello, world!")
and mark it as executable (chmod +x /tmp/test.py), I can just execute it as /tmp/test.py like I would do with any bash file.

If you mean invocation as "execute a command that I'm passing", 'python -c' does exactly that.

Even as a complete shell it works including changing directories and using standard python to do file IO, though it won't execute any system executables and doesn't do piping like you'd like from a shell. It's not intended for that purpose so I can't really blame python for that.

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#48
post #44

Earlier quoted context omitted.

I still think one of Go’s best contributions was formatting with ‘go fmt’. It’s refreshing to see so many language communities just embrace a format on save standard and keep it moving. Reading Python has always been a bit of a headache for me, but that probably has as much to do with the lack of type annotations as it does the lack of braces.

Auto formatters are the future, why should humans ever have to manually format or discuss how it should look ever again. However, languages that have a line length limit are the blight of them. There isn't a python formatter that won't make everything mush. My if clause that is 81 chars wide doesn't need to be broken up. Similar, my strings don't need to be reflowed. Go fmt ignores line length, and always produces a…

You can change the max line length in black (the Python formatter I hear mentioned most often). How would you feel about setting it to something really large, like 1000, to emulate having no line length limit?

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#49
post #42

It's a shame Python doesn't natively support easy invocation from command line. It really shoots down a whole class of applications where bash is getting used but Python would be so much better. I've ended up using Groovy for this level of scripting, and it works really well.

[deleted]

Re: Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces)

#50
post #44

Earlier quoted context omitted.

Auto formatters are the future, why should humans ever have to manually format or discuss how it should look ever again. However, languages that have a line length limit are the blight of them. There isn't a python formatter that won't make everything mush. My if clause that is 81 chars wide doesn't need to be broken up. Similar, my strings don't need to be reflowed. Go fmt ignores line length, and always produces a…

You can change the max line length in black (the Python formatter I hear mentioned most often). How would you feel about setting it to something really large, like 1000, to emulate having no line length limit?

That doesn't work still. It will reflow all your lines to reflow to 1000. Try it out, anything above 88 makes even the cleanest python a nightmare.

I don't like long lines, but reflowing logic is way to aggressive in these formatters.

Post reply on HN