Live data from Hacker News

Think Python, 3rd Edition

allendowney.github.io

81–90 of 126 posts

Re: Think Python, 3rd Edition

#81
Hey genuine question,

Why would anyone bother with learning anymore? When is learning enough to get started?

How will someone get started with work? What qualifies someone to start a new position?

Pretty sure only smart people will be hired for the roles.

No matter what I do, I am forever unqualified, even from junior roles.

1. Have post grad degree

2. Have internships

3. Have only part time or short tenure roles.

But can't get into any industrial role. Why?

Means, I die? What qualifies for a job?

Well one option is to go back to shithole country I came from and just stay there earning pennies. With the money I make there affording a new mac will take 2 years salary. So that is the kind of shithole I am talking about.

Seriously, why?

Re: Think Python, 3rd Edition

#82

Hey genuine question, Why would anyone bother with learning anymore? When is learning enough to get started? How will someone get started with work? What qualifies someone to start a new position? Pretty sure only smart people will be hired for the roles. No matter what I do, I am forever unqualified, even from junior roles. 1. Have post grad degree 2. Have internships 3. Have only part time or short tenure roles. Bu…

>Pretty sure only smart western people will be hired for the roles.

Everywhere I've ever worked in tech, in my 20 year career, has had people from all backgrounds.

Re: Think Python, 3rd Edition

#83

Apologies for changing the subject, but aside from real world experience (which I have and am getting at work), is there a resource of similar quality for more intermediate/advanced Python programmers? I always feel like there's a big chunk of the language or stdlib I do not know.

It’s a bit older, but I learned a lot from “Writing idiomatic Python”. Honorable mention to “the little book of Python antipatterns” as well.

Links for anyone else interested as I was

https://jeffknupp.com/writing-idiomatic-python-ebook/

https://docs.quantifiedcode.com/python-anti-patterns/

Re: Think Python, 3rd Edition

#84
post #6

Tangential, is there a book to learn typing? I feel I need a hefty book to learn typing. Don't mind if you recommend a Typescript book or other language with similar concepts.

You mean types, right? Typing is what you do on a keyboard. If you want to understand type systems, Types and Programming Languages ( https://www.cis.upenn.edu/~bcpierce/tapl/ ) is the book most people start with. If that is too advanced for you, PLAI ( https://www.plai.org/ ) is a gentle introduction to programming language theory which includes type systems.

The source of several jokes of course https://stackoverflow.com/questions/430182/is-c-strongly-typ...

Re: Think Python, 3rd Edition

#85
post #46

Earlier quoted context omitted.

Use asyncio. Bind to a socket, set blocking False, then asyncio.run(on_new_connection(sock)). Inside that coroutine get the loop and await loop.sock_accept(sock) And then asyncio.create_task(on_connection_data(connection)). The only gotcha is you need to keep a reference to that task so it doesn't get garbage collected.

Get garbage collected by what? Doesn’t Python use reference counting?

Python has a GC.

Re: Think Python, 3rd Edition

#86
post #70

Earlier quoted context omitted.

> Honestly I’m not sure this is a good use case for Python but it’s definitely possible It definitely isn't, but this is a new role with a rushed timeline in a place dominated by Python. > and it works but I find the code extremely hard to reason about This is also a major concern of mine.

Rather than handling the multiprocessing and message passing yourself it would be much easier to use celery + gevent and let celery do the work of spinning up processes for executing the tasks. It may feel limiting but my advice would be to keep all the celery job queue stuff isolated from your server, especially if you are using an async web framework. Have your web server just put all the jobs in the celery queue a…

Can Celery help handle state internal to the workers?

What about using Pkykka alongside Pyro such that each Pyro remote object is actually a Pykka actor? Such that Pyro allows splitting workers across separate Python OS processes and the "messaging" while Pykka handles the internal state.

Re: Think Python, 3rd Edition

#87

I love these books … in my case Think Perl6 (now Think Raku) was a real eye opener. A quick scan of the new Python 3rd edition looks like it is quite dumbed down - which is probably appropriate for Python. I highly recommend the intro to Functional Programming in Raku (chapter 14). https://greenteapress.com/wp/think-perl-6/

Cool, I didn't know about this book! I enjoyed Think Python, but this book surprises me. I'd think there are very few people learning Perl / Raku as their first language nowadays, so a book targeting more experienced programmers seems like it would make a lot more sense.

Re: Think Python, 3rd Edition

#88
I particularly enjoyed this passage from an older edition of Think Java: https://files.catbox.moe/v1vgdc.jpg

Also neat:

> What happened next is the cool part. Jeff Elkner, a high school teacher in Virginia, adopted my book [Think Java] and translated it into Python. He sent me a copy of his translation, and I had the unusual experience of learning Python by reading my own book.

Re: Think Python, 3rd Edition

#90
post #46

Earlier quoted context omitted.

Use asyncio. Bind to a socket, set blocking False, then asyncio.run(on_new_connection(sock)). Inside that coroutine get the loop and await loop.sock_accept(sock) And then asyncio.create_task(on_connection_data(connection)). The only gotcha is you need to keep a reference to that task so it doesn't get garbage collected.

Get garbage collected by what? Doesn’t Python use reference counting?

The reference implementation (CPython) does use reference counting, but that is not its only approach to garbage collection.

"The default build implementation is a generational collector. The free-threaded build is non-generational; each collection scans the entire heap."

https://devguide.python.org/internals/garbage-collector/

https://docs.python.org/3/library/gc.html

(And as someone else pointed out, asyncio's event loop keeps only weak references to tasks, so the GC implementation doesn't really matter here.)

Post reply on HN