Skip to content

Error calling ElementaryParticle(spin).hear_me() #3

@ostueker

Description

@ostueker

Cell [29] in notebook ch06-classes-objects.ipynb gives an error as the (overloaded) constructor of the ElementaryParticle class doesn't create the data attributes initialized bu the generator of the Particle class.

This can be solved by calling Particle.__init__(self) explicitly:

# elementary.py
class ElementaryParticle(Particle):

    roar = "I am an Elementary Particle!"

    def __init__(self, spin):
        Particle.__init__(self)
        self.s = spin
        self.is_fermion = bool(spin % 1.0)
        self.is_boson = not self.is_fermion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions