Git Product home page Git Product logo

Comments (1)

CodeMouse92 avatar CodeMouse92 commented on August 18, 2024

Hi Kirill!

I'll start with (2), as you are absolutely right. While @typing.overload should work as I describe normally, it doesn't play well with other decorators. That was a major oversight on my part. Thankfully, my publisher is reprinting the book, so we'll get that fixed.

As to (1), you're definitely correct that if 1 in formula.keys(): fails. That should have checked for H instead. Not sure how I overlooked that obvious detail.

As to the concern about the possible brittleness of using __hash__() like this, I'm not terribly concerned. I did write the classes to depend on that implementation detail, so the element symbol (guaranteed unique for all real elements entered correctly) is used as the unique identifier. You're correct that it tightly couples Element and Compound, but that's one of those acceptable little compromises to make a sane example. In fact, this is one of my least favorite examples in the book...it took me three weeks to develop, and I was fairly going out of my mind by time I finished it. On the upside, it shows how hashes are used, and that makes the compromise a bit valuable in itself.

Thanks for your comments!

from deadsimplepython.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.