Skip to content

Classes #24

Open
Open

Description

@arm61

Write a section introducing classes:

  • class variables
  • class methods/functions
  • the @property decorator
  • docstrings for classes

Activity

  1. RMeli commented on May 4, 2020

    @RMeli
    Contributor

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

  2. RMeli commented on Jun 12, 2020

    @RMeli
    Contributor

    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.

  3. RMeli commented on Jun 15, 2020

    @RMeli
    Contributor

    I suggest the following discussion for the advanced section:

    • @property decorator
      • Use to set self.elements attribute with valid elements only
    • Inheritance
      • Linked to Introduction to OOP #65: Molecule inherit from SimpleMolecule to avoid duplication of code (__init__ method)

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

  4. RMeli commented on Jun 15, 2020

    @RMeli
    Contributor

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

  5. arm61 commented on Jun 16, 2020

    @arm61
    ContributorAuthor

    So using a graph network to describe a molecule?

  6. RMeli commented on Jun 16, 2020

    @RMeli
    Contributor

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

  7. arm61 commented on Jun 16, 2020

    @arm61
    ContributorAuthor

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

  8. RMeli commented on Jun 16, 2020

    @RMeli
    Contributor

    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.

  9. RMeli commented on Jul 1, 2020

    @RMeli
    Contributor

    I was thinking of the following for the advanced section:

    • Extension for the Molecule class
      • Introduce more dunder methods
        • __repr__
        • __len__ and __getitem__ to get atoms
        • __iter__ to loop over atoms (maybe too advanced if needs to introduce iterators?)
      • Introduce decorators and @property
    • Introduction to inheritance
      • Inherit a molecule from networkx.Graph
      • Explain the drawbacks of this approach

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

  10. removed their assignment
    on Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needednew contentSome new content for the book

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions