pythoninchemistry / intro_python_chemists

An open-source, online textbook introducing Python programming to chemistry students
https://pythoninchemistry.org/intro_python_chemists
BSD 3-Clause "New" or "Revised" License
23 stars 6 forks source link

Classes #24

Open arm61 opened 4 years ago

arm61 commented 4 years ago

Write a section introducing classes:

RMeli commented 4 years ago

@arm61 I can take this on with #23 if you want. I'll come up with a first ToC in the coming days so that we can agree on the general outline.

RMeli commented 4 years ago

Attributes, methods and docstrings for classes are discussed in #65.

I think the @property decorator can be easily introduced to extend the Molecule class further (for example by checking that all the element numbers are valid in the setter), in an advanced section.

RMeli commented 4 years ago

I suggest the following discussion for the advanced section:

Please let me know if other useful concepts should be added.

RMeli commented 4 years ago

Scratch that. What about a short introduction to networkx and show inheritance by deriving a molecule from networkx.Graph?

arm61 commented 4 years ago

So using a graph network to describe a molecule?

RMeli commented 4 years ago

Yes, something like A Minimal Molecule API, but simplified.

arm61 commented 4 years ago

Not opposed to the idea. In particular, cause so much of Python is about building on top of other packages.

RMeli commented 4 years ago

Yes, that's what I was thinking. Instead of creating something from scratch to describe inheritance I think it's good to show that you can actually inherit from third-party libraries and avoid re-inventing the wheel.

This week I'm very busy, but I'll sketch out the advanced OOP section the coming weekend or next week.

RMeli commented 4 years ago

I was thinking of the following for the advanced section:

Do you have any other suggestion on what should (or shouldn't) be included?