News for hackers. Stuff that matters.
Re:Pytudes: Python programs for perfecting particular progra... by mark_l_watson on Monday December 27, 2021 @09:50AM (#29702884)
What I find interesting is how Peter builds bottom up solutions using low level utilities. This is how I have always coded in Lisp languages, but when I use Python I tend to write little monoliths. Since I now have to use Python for most of my work (deep learning), I should change the way I use Python. Reading his code is educational.

Peter and I each wrote a Common Lisp book about 25 years ago and a few years after that we had lunch and I was into Lisp and he had transitioned to the practicality of Python. I have a serious bias in favor of Lisp languages that probably has not served me very well. I once had a short talk with Alexis Ohanian about how he and his partner Steve had to convert Reddit from Common Lisp to Python, I think that he described the situation as something like “the Lisp version kept falling down.”

Re:Pytudes: Python programs for perfecting particular progra... by wirthjason on Monday December 27, 2021 @01:25PM (#29705142)

    My recent books can be downloaded for free (or optionally pay for them) at https://leanpub.com/u/markwatson
This is really cool. Thank you!
Re:Pytudes: Python programs for perfecting particular progra... by uyt on Monday December 27, 2021 @06:09AM (#29701437)
Seems like he didn't have time to finish Advent of Code this year. I was looking forward to seeing his code for some of the puzzles I struggled with!

While there are plenty of other solutions and discussions in the megathreads for each day: https://www.reddit.com/r/adventofcode/wiki/solution_megathre...

It is mostly dominated by competitive programmers who value speed over readability. When it comes to presenting a solution, Peter Norvig's style, clarity and craftsmanship is unmatched.

Re:Pytudes: Python programs for perfecting particular progra... by DarkCrusader2 on Monday December 27, 2021 @07:49AM (#29702074)
Same, and it made me feel less guilty about myself for abandoning AoC for a second year (after 17 days in 2019 and 19 days this year). It becomes just too time consuming after around 17-18 days since I am not a genius.
Re:Pytudes: Python programs for perfecting particular progra... by wirthjason on Monday December 27, 2021 @07:36AM (#29701993)
I find Norvig’s style of Python a bit odd as it diverges from PEP-8ish style I’m accustomed to. Nothing wrong with it but he’ll redefine things, put functions on one line, etc. The good thing is that I challenges my understanding of what you can do with the language and how simple and expressive it can be.

For example I found this line of code cute. So much going on — no function definition, just a string literal method being assigned to a name (which any Linux programmer would get but a windows one may not).

    cat = ''.join
Re:Pytudes: Python programs for perfecting particular progra... by globular-toast on Monday December 27, 2021 @08:28AM (#29702321)
As a Python and Linux user for more than ten years that kind of thing gives me pause. It's great for recreational code as it expands the mind, but terrible for professional code. Idiomatic usage is really important in professional code. You want it to be like Cypher looking at the Matrix; "I don't even see the code, all I see is function, loop, conditional".
Re:Pytudes: Python programs for perfecting particular progra... by BenFrantzDale on Monday December 27, 2021 @08:40AM (#29702415)
I like that Python let’s you name `’’.join`. I’ve done the same thing creating a linear form: `f = x.dot`.
Re:Pytudes: Python programs for perfecting particular progra... by marai2 on Monday December 27, 2021 @09:10AM (#29702615)
And j = json.loads

For quick debugging:

print( j( some_data_structure ))

For some data structure that you'll eventually be sending out as json.

Re:Pytudes: Python programs for perfecting particular progra... by vmilner on Monday December 27, 2021 @05:51AM (#29701347)
"Etudes for Programmers" is such a brilliant book. I first came across it 1991:

https://openlibrary.org/books/OL4546158M/Etudes_for_Programm...

Re:Pytudes: Python programs for perfecting particular progra... by cinntaile on Monday December 27, 2021 @06:13AM (#29701469)
Is it similar to Programming Pearls?
Re:Pytudes: Python programs for perfecting particular progra... by vmilner on Monday December 27, 2021 @06:57AM (#29701750)
I think the projects are larger - or at least move from small ones like quines:

https://en.wikipedia.org/wiki/Quine_(computing)

)

to large ones writing simple compilers.

Good (accurate) review at:

http://www.computinghistory.org.uk/det/12325/Etudes-for-Prog...

and interviews with the author:

https://demin.ws/blog/english/2012/08/25/interview-with-char...

https://sudonull.com/post/27422-Breakfast-report-with-Charle...

Re:Pytudes: Python programs for perfecting particular progra... by immortal3 on Monday December 27, 2021 @06:19AM (#29701509)
You can view ipython notebook easily with nbviewer. (sometime github rendering fails for large notebooks)

This year AOC 2021: https://nbviewer.org/github/norvig/pytudes/blob/main/ipynb/A...

Re:Pytudes: Python programs for perfecting particular progra... by katelatte on Monday December 27, 2021 @03:24AM (#29700583)
This is so cool, I'm still learning Python, so this may come in handy. Thanks for sharing. I also participated in AOC 2021, but didn't make it till the end :') In which part of the day did you solve the assignments most often?