79830328

Date: 2025-11-26 04:25:02
Score: 1
Natty:
Report link

''' I just fixed this in my own code base. I've already wasted too much of my life trying to paste code without my entire post becoming a code box, so stackoverflow doesn't get an explanation. Ask ChatGPT I guess.'''


from dataclasses import dataclass

# Parent code
@dataclass
class _Parent:
    name: str
    age: int

    def print_name(self):
        print(self.name)

    def print_age(self):
        print(self.age)

    def print_id(self):
        print(f'The Name is {self.name} and {self.name} is {self.age} year old')

@dataclass
class Parent(_Parent): 
    ugly: bool = False


@dataclass
class _Child(_Parent):
    school: str

@dataclass
class Child(Parent, _Child):
    ugly: bool = True


jack = Parent('jack snr', 32, ugly=True)
jack_son = Child('jack jnr', 12, school = 'havard', ugly=True)

jack.print_id()
jack_son.print_id()
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Joseph Rissler