Live data from Hacker News

Think Python, 3rd Edition

allendowney.github.io

61–70 of 126 posts

Re: Think Python, 3rd Edition

#61
post #54

Earlier quoted context omitted.

Can you give an example of what you consider a good solution in a different language? That will help us see exactly what you're looking for and how/whether it might be achieved in Python.

Erlang and Elixir. :)

Well RabbitMQ is built in Erlang so there you go :)

Re: Think Python, 3rd Edition

#62
post #54

Earlier quoted context omitted.

Erlang and Elixir. :)

Well RabbitMQ is built in Erlang so there you go :)

But RabbitMQ is just a messaging bus, isn't it? That doesn't handle the processes (operating system processes or virtual processes) actually processing the messages and those processes handling fault-tolerance for the things they're connected to.

Re: Think Python, 3rd Edition

#63
post #62

Earlier quoted context omitted.

Well RabbitMQ is built in Erlang so there you go :)

But RabbitMQ is just a messaging bus, isn't it? That doesn't handle the processes (operating system processes or virtual processes) actually processing the messages and those processes handling fault-tolerance for the things they're connected to.

That is correct. Honestly I’m not sure this is a good use case for Python but it’s definitely possible. I’ve used the RabbitMQ + gevent + multiprocessing pattern in the past and it works but I find the code extremely hard to reason about. If I were doing it again from scratch I’d probably choose another language with better concurrency primitives.

Re: Think Python, 3rd Edition

#64

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.

Fluent Python and Effective Python are good books. The former is huge and is really multiple books in one.

Re: Think Python, 3rd Edition

#65
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?

asyncio doesn't store strong references to tasks. It is your responsibility to keep the ref: https://docs.python.org/3/library/asyncio-task.html#asyncio....

Consider organizing the code using TaskGroup.

Re: Think Python, 3rd Edition

#68

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.

I like https://effectivepython.com/

Also just reading Norvig’s annual Advent of Code implementations usually provides some insight on how to write elegant and concise Python code.

Re: Think Python, 3rd Edition

#69

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.

I learned Python starting with 1.5.2 from the official documentation and think it's a good resource.

https://docs.python.org/3/tutorial/index.html

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

Whenever a new version is released, I read its What's New documentation.

Beyond that, I like to read source code, both for the stdlib and popular third-party packages. This advice generally applies when I'm learning any new language or re-familiarizing myself with one, not just Python.

Re: Think Python, 3rd Edition

#70
post #62

Earlier quoted context omitted.

But RabbitMQ is just a messaging bus, isn't it? That doesn't handle the processes (operating system processes or virtual processes) actually processing the messages and those processes handling fault-tolerance for the things they're connected to.

That is correct. Honestly I’m not sure this is a good use case for Python but it’s definitely possible. I’ve used the RabbitMQ + gevent + multiprocessing pattern in the past and it works but I find the code extremely hard to reason about. If I were doing it again from scratch I’d probably choose another language with better concurrency primitives.

> 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.

Post reply on HN